Not until 1249 did King Afonso III (1248-1279) complete the Reconquest and secure borders for Portugal 250 years before the Spanish could do the same.
Portugal's borders were not secured by King Afonso the third until 1249.
It was King Afonso the third that defended Portugals borders from Spain.