The first castle, named the Grand Châtelet, was built on the site by Louis VI in around 1122. The castle was expanded by Saint Louis in the 1230s. It was burned by the Black Prince in 1346; of it, only the Gothic chapel remains. This Château Vieux was rebuilt by King Charles V in the 1360s on the old foundations. The oldest parts of the current château were reconstructed by François I in 1539, and have subsequently been expanded several times. Henri II built a separate new château (le Château Neuf) nearby, to designs by Philibert de l'Orme, sited at the crest of a slope, which was shaped, under the direction of Étienne du Pérac (Karling 1974 p 10) into three massive descending terraces and narrower subsidiary mediating terraces, which were linked by divided symmetrical stairs and ramps and extended a single axis that finished at the edge of the Seine; the design took many cues from the Villa Lante at Bagnaia. "Étienne du Pérac had spent a long time in Italy, and one manifestation of his interest in gardens of this type is his well-known view of the Villa d'Este, engraved in 1573" (Karling 1974, p 11).
The gardens laid out at Saint-Germain-en-Laye were among a half-dozen gardens introducing the Italian garden style to France that laid the groundwork for the French formal garden. Unlike the parterres that were laid out in casual relation to existing châteaux, often on difficult sites originally selected for defensive reasons, these new gardens extended the central axis of a symmetrical building façade in rigorously symmetrical axial designs of patterned parterres, gravel walks, fountains and basins, and formally-planted bosquets; they began the tradition that reached its apex after 1650 in the gardens of André Le Nôtre. According to Claude Mollet's Théâtre des plans et jardinage the parterres were laid out in 1595 for Henri IV by Mollet, trained at Anet and the progenitor of a dynasty of royal gardeners. One of the parterre designs by Mollet at Saint-Germain-en-Laye was illustrated in Olivier de Serre's Le théâtre d'agriculture et mesnage des champs (1600), but the Château Neuf and the whole of its spectacular series of terraces can be fully seen in an engraving after Alexandre Francini, 1614.
Louis XIV was born at Saint-Germain-en-Laye in 1638. One of du Pérac's retaining walls collapsed in 1660, and Louis undertook a renovation of the gardens in 1662. At his majority he established his court here in 1666, but it was the Château Vieux that he preferred: the Château Neuf was abandoned in the 1660s and demolished. From 1663 until 1682, when the king removed definitively to Versailles, the team that he inherited from the unfortunate Fouquet— Louis Le Vau, Jules Hardouin-Mansart and André Le Nôtre laboured to give the ancient pile a more suitable aspect.
Louis XIV turned the château over to King James II after his exile from Britain in the Glorious Revolution of 1688. King James lived in the château for thirteen years, and his daughter Marie-Louise Stuart was born in exile here in 1692. King James Stuart is buried in the nearby Church of Saint-Germain; his descendants stayed at the château until the French Revolution, leaving in 1793.
In the 19th century, Napoleon I established his cavalry officers training school here. Napoleon III had the castle restored by Eugène Millet from 1862, and it became the Musée des Antiquités Nationales (Museum of National Antiquities) in 1867, displaying the archeological objects of France.
During the German occupation (1940-44), the château served as the headquarters of the German Army in France.