The name Louvre first appears in the twelfth century, attached to a fortress that Philip II built on the right bank of the Seine, just outside the city wall. Its purpose was defensive: a keep 30 metres high, a moat fed by the river, and a garrison to watch the approach to Paris from the west. The foundations of that castle were rediscovered in 1984 during the Grand Louvre works and can still be visited in the Salle Basse, beneath the Cour Carree.
Charles V turned the fortress into a residence in the 1360s, adding windows, gardens and a library. Two centuries later Francis I demolished the keep and commissioned Pierre Lescot to build a Renaissance palace on the same site. Francis also began the royal art collection, buying Italian paintings and inviting Leonardo da Vinci to France — the route by which the Mona Lisa entered the possession of the French crown.
When Louis XIV moved the court to Versailles in 1682, the Louvre was abandoned mid-construction. It was occupied instead by royal academies and by artists who were given lodgings and studios there, and the Grande Galerie became a place where painters could study the royal collection. That arrangement lasted more than a century, and it is the reason the building was already half a museum before the Revolution made it one.