The ancient fortification had its base in a Lusitanian castro settlement, that likely existed between the Neolithic to Chalcolithic transition. It was conquered by the Romans, in 198 AD, and transformed into a military base that was served by the ports of Armação and Pera.
During its occupation by north African Arabs in the 12th century, the ancient stone walls were constructed, allowing the protection of the space until the 13th century. It is likely that the civil parish/village first received its name from the Arabic "al-qantarâ", named from a local bridge, on the road between two of the more prestigious provinces of Al-Andalus (Faro and Silves). The castle was conquered from the Moors by D. Paio Peres Correia, during the reign of Afonso III of Portugal, who sought to command the area by re-building the castle walls.
The walls were strengthened and remodeled during the 16th century, under King Sebastian of Portugal, who controversially resulted in the dis-figuration of the Muslim castle. In 1573, when the monarch passed through the locality, he was determined to improve the redoubt, whose strategic importance continued during this epoch: it was seen as a bastion to maritime attacks and guarded areas that could be used as eventual disembarkation points.
Although, there were reports that the structure sustained major damages following the 1755 Lisbon earthquake there were no documented resources that confirm the extent of these damages. Yet, it is clear that its decline began after this period.
It was similarly restored after the Portuguese Restoration Wars in order to defend the region from Spanish attacks.