Answer
Portugal gained its independence shortly after the death of Alfonso VI in 1139. Afonso Henriques, Count of Portugal, took advantage of his mother, Queen Teresa's, unpopularity and the political instability in the kingdom of León to establish Portugal as an independent nation. His victory at the Battle of Ourique in 1139 cemented Portugal's independence, which was ultimately recognized by Alfonso VII of León in 1143.