The building was likely built at the end of the 12th century as a mosque [REF].
By the middle of the 16th century, though, Pedro Dias described the changes to the building: the minaret had already been substituted for a belltower and the roofline had become adorned with merlons, which crown the roof of the building (authored by Fernão Pires) [REF].