The hilltop was fortified even before the arrival of the Roman legions; in later centuries the castle walls were strengthened by Visigoths and Moors, before falling to Portugal's first king, Afonso Henriques, in 1147. His statue stands in the square just past the main gate. From the 14th to the 16th centuries, Portugal's kings resided in the Palácio de Alcaçovas, the remains of which now house a snack bar and a display of finds from the ongoing archaeological digs.
The castle itself has undergone numerous transformations. Back in the 1930s, several government offices and a firehouse were removed from the grounds, exposing the walls, which were duly topped with supposedly authentic-looking battlements. There have been several makeovers since then. The battlements of the Castelejo (keep) have ten towers, which may be climbed; in one is a Cámara Obscura (10am-5pm) from which you can see key city monuments and spy on people downtown, as well as learning how the contraption works.
Beyond the keep is an area where labelled displays trace out dwellings from prehistoric times and the late Islamic period, as well as the ruins of the last palatial residence on this hill, destroyed by the 1755 earthquake.