The Treaty of Zamora (1143) recognized Portuguese independence from the Kingdom of Leon and Castile.
Thanks to the victory of Afonso I of Portugal, in the battle of Ourique in 1139, against Muslims, Afonso I of Portugal won the support of the Archbishop of Braga, who favored the establishment of the new kingdom of Portugal.
The vision of D. Afonso Henriques.
Meanwhile, Alfonso VII of León and Castile regarded the independent ruler of Portugal as nothing but a rebel. Both kingdoms were in conflict during the following years.
"The Miracle of Ourique" by Domingos Sequeira (1793): Part of Portuguese Reconquista.
Finally, the Treaty of Zamora in 1143 established peace between both kingdoms and the Portuguese independence.
Both kings were busy trying to expel the Muslim invasion of the Iberian Peninsula.