After the outbreak of the Thirty Years' War Maximilian made a treaty with the emperor Ferdinand II. in Oct. 1619, and in return for large concessions placed the forces of the league at the emperor's service. He made a treaty of neutrality with the Protestant Union, and occupied Upper Austria as security for the expenses of the campaign. On Nov. 8, 162o, his troops under Count Tilly defeated the forces of Frederick, king of Bohemia, at the White Hill near Prague. Tilly then devastated the Rhenish Palatinate, and in Feb. 1623, Maximilian was formally invested with the electoral dignity and the attendant office of imperial steward, which had been enjoyed since 1356 by the counts pala tine of the Rhine. After receiving the Upper Palatinate and restoring Upper Austria to Ferdinand, Maximilian became leader of the party which sought to bring about Wallenstein's dismissal from the imperial service. At the diet of Regensburg in 163o Ferdinand was compelled to assent to this demand, but the sequel was disastrous both for Bavaria and its ruler. Early in 1632 the Swedes marched into the duchy and occupied Munich, and Maxi milian had to place himself under the orders of Wallenstein, now restored to the command of the emperor's forces. The ravages
of the Swedes and their French allies induced the elector to enter into negotiations for peace with Gustavus Adolphus and Cardinal Richelieu. He also proposed to placate the Protestants by modi fying the Restitution edict of 1629; but these efforts were abor tive. In March 1647 he concluded an armistice with France and Sweden at Ulm, but the entreaties of the emperor Ferdinand III. led him to disregard his undertaking. Bavaria was again ravaged, and the elector's forces defeated in May 1648 at Zusmarshausen. By the treaty of Westphalia it was agreed that Maximilian should retain the electoral dignity, which was made hereditary in his family; and the Upper Palatinate was incorporated with Bavaria. The elector died at Ingolstadt on Sept. 27, 1651.