The Moors built it in the 8th and 9th centuries as the stronghold of a mainly farming district, and it became a key position during the Reconquista. From the top, the view takes in the municipality of Sintra and, on clear days, Mafra and Ericeira. Portugal classifies it as a National Monument, and UNESCO includes it in the World Heritage listing of the Sintra Cultural Landscape.

After forces loyal to Afonso Henriques took Lisbon in 1147, the castle surrendered to the Christians without a fight. The king placed it in the care of 30 inhabitants, whose privileges he confirmed in a charter of 1154, and a chapel inside the walls became the seat of the parish. Ferdinand I ordered the castle rebuilt in 1375, yet people gradually moved down to the village of Sintra; the chapel was later used by a small Jewish community until Manuel I expelled the Jews, and the fortress was left empty. The 1755 earthquake damaged it further, and by 1838 its towers lay in ruins.

The castle visitors walk today owes much to Ferdinand II, who from 1840 strengthened the walls, planted trees on the slopes, laid out paths and conserved the chapel; Wilhelm Ludwig von Eschwege oversaw the work. Beside the chapel he raised a monument to hold the bones found during the works. The result is a Romantic ruin, with vegetation both native and exotic around and inside the walls, and towers that have lost the floors and roofs they once had.

Entry is either from Santa Maria e São Miguel through a guarded gate with a turnstile, or by crossing a road from the Palace of Pena. Paths wind up from the outer wall to a second ring with round and square turrets topped by pyramid-shaped merlons, whose main gate is flanked by two turrets. Inside lie the remains of cellars and animal pens, an underground cistern 18 metres long, which once collected rainwater through openings in its roof, and storage silos dating from the Arab period. The highest point is the royal tower in the south-west corner, and a small Traitors Gate on the north side opens onto the inner yard.

Outside the second wall, near the entrance, are the ruins of the chapel of São Pedro, with carved capitals showing plants, griffins and basilisks and traces of frescoes in its vaulted apse. Excavations there in 1979 found medieval tombs from around the turn of the 13th century. Because the chapel stands within the castle, a tradition grew up that it had been a mosque, though no evidence links this building to one. The hilltop is noticeably cooler, foggier and wetter than Lisbon, with fog especially frequent in June.