Maximilian Emanuel was again forced to flee the Netherlands after the Battle of Ramillies on 23 May 1706 and found refuge at the French court in Versailles where his late sister Maria Anna (1660–1690) had been the wife of the "Grand Dauphin". In 1712, Luxemburg and Namur were ceded to Maximilian Emanuel by his French allies, a cession that was not definitive since France was only the occupant of what was still the Spanish Netherlands. The war between France and Austria finally ended in 1714 in the Treaty of Rastatt in which Louis XIV compelled Austria to implement the full restoration of his faithful ally Maximilian Emanuel, including the return of the Upper Palatinate. Maximilian Emanuel was to remain in possession of Luxemburg, Namur and Charleroi until he was restored.