Most of the castle was built in 713 by the Moors. However, its history and that of the town goes back to Roman times. Parts of the castle might have been around since the Visigoths conquered Óbidos in the 5th Century.