The fortress played a most important role in the fights for the nationality formation, conquered from the moors by King Afonso Henriques in 1167.