During the Middle Ages, the Louvre was not a museum, but a fortress. It was built in the late 12th century by King Philip II Augustus as part of the city's defensive wall. The Louvre was a key part of the city's defense system, and it was used to protect Paris from attack. The fortress was originally a square-shaped structure with four corner towers. The towers were used as lookout posts, and they were also used to store weapons and supplies. The walls of the fortress were made of thick stone, and they were high enough to make it difficult for attackers to climb over them. The only entrance to the fortress was a drawbridge, which could be raised to keep out intruders.
In the 14th century, the Louvre was expanded and converted into a royal residence. The French royal family lived in the Louvre until the 17th century, when they moved to the Palace of Versailles. The Louvre continued to be used as a royal palace until the French Revolution in 1789. During the Revolution, the Louvre was briefly used as a prison. In 1793, the Louvre was turned into a museum, and it has remained a museum ever since.