Not only did it have the purpose of guarding the road that connected the two cities, but it was his first act of aggression directed at Muslims, as the garrison was also obliged to attack the territory of Santarém.
In the Battle of Ourique, the Portuguese defeated the Almoravid troops commanded by a certain "Esmar", in 1139.
[1] Esmar knowing that the king of Portugal was in Galicia and was suffering setbacks, he regrouped his troops and attacked the castle of Leiria, which he conquered, razed and massacred its garrison, taking prisoners of those who were captured alive.
[1] Upon learning of what had happened, Afonso I of Portugal signed a truce with his cousin and traveled from Galicia to Trancoso to fight the Muslims, whom he destroyed in two encounters.
[1] In the aftermath of the battle, he founded the monastery of Tarouca in the presence of his troops.