The name Obidos is derived from the Latin for citadel and this is its castle.
Originally 12th century it was extensively damaged in the 1755 earthquake and much of what you see now has been rebuilt.
These days it is a pousada (hotel) rather than fortress