Castellar de la Frontera is a town and municipality in the province of Cádiz, in the Andalusia region of southern Spain. It lies within the Campo de Gibraltar area, near the southern tip of the Iberian Peninsula.
The settlement is notable for being a medieval town contained within a castle. This fortified old town, known as Castellar Viejo, sits on a hilltop and preserves its historic layout inside the castle walls.
Alongside the historic core, the municipality includes newer development on lower ground, reflecting the town's dual character as both a preserved medieval site and a modern residential community.