Óbidos had its foundation in the existence of a fortified settlement, likely over the Luso-Roman castro[1] and Roman oppidum (then civitas) on the hilltop, that was the mysterious Eburobrittium, once cited by Pliny the Elder as being situated between Collipo (near present-day Leiria) and Olisipo (Lisbon). Archeological surveys later resulted in the discovery of a forum, baths and other Roman structures near the settlement. The area was later settled by the Lusitanos (since the 4th century BC) and Romans in the first century, but later occupied by Visigoths during the 5th and 6th century and Muslims, who were responsible for fortifying the town in the 8th century.
During the Christian Reconquista, forces under the first Portuguese king Afonso I (1112–1185) defeated the settlement's defenses through a ruse, on 10 January 1148. The first surveys of the castle were undertaken in 1153, although the castle was never completely conquered until the reign of King D. Sancho I (in 1195), as documented in the epigraph Torre do Facho. Also at this time, the Albarra tower was converted into a jail, when the walls were reformulated by King Sancho I. The old dungeon was restored and expanded by King D. Denis, while the barbicans alongside the main gate was constructed