Begun by Jaume II in 1300 and built by Pere Salva, the architect of the Almudaina Palace, it is unique among Spanish castles in being entirely round. Three large towers surround a central courtyard, connected by an arch to a free standing keep. The courtyard itself is on two levels, the ground floor with semicircular arches and a flat roof, the upper level with Gothic arches and rib-vaulting. It was conceived as a defensive installation and royal residence. But it became most famous, or infamous, as a prison, from the Middle Ages until the Civil War.