Jerez was a frontier town that went back and forth between Moors and Christians, and this fortress was built in the 12th century as a rural outpost to hold the line against Christian encroachment. It contains an austerely beautiful mosque, lovely gardens, and some of the best-preserved Moorish baths in Andalucía. Although the mosque was converted to a church in 1264, the mihrab, or prayer niche, was preserved—as was the boiler system of the baths, enabling you to see how they operated. The alcázar also functions as a local history museum, displaying two of the ancient olive mills. (In the 1700s, Jerez had 32 active olive mills.) The fortress also contains the Palacio Villavicencio, a noble palace constructed from the late 1600s to 1927. Its history paintings are mostly remarkable for their immense size. A tower room contains a camera obscura, which projects images of the city in a darkened room.