When he had succeeded to the throne of the Duchy of Bavaria in 1597, Maximilian I had found it encumbered with debt and filled with disorder, but ten years of his vigorous rule effected a remarkable change.
The finances and the judicial system were reorganised, a class of civil servants and a national militia founded, and several small districts were brought under the duke's authority.
Maximilian's son, Ferdinand Maria (1651–1679), who was a minor when he succeeded, did much indeed to repair the wounds caused by the Thirty Years' War, encouraging agriculture and industries, and building or restoring numerous churches and monasteries.
His constructive work, however, was largely undone by his son Maximilian II Emanuel (1679–1726), whose far-reaching ambition set him warring against the Ottoman Empire and, on the side of France, in the great struggle of the Spanish succession.
Untaught by Maximilian II Emmanuel's experience, his son, Charles Albert (1726–1745), devoted all his energies to increasing the European prestige and power of his house.
The price he had to pay, however, was the occupation of Bavaria itself by Austrian troops; and, though the invasion of Bohemia in 1744 by Frederick II of Prussia enabled him to return to Munich, at his death on 20 January 1745 it was left to his successor to make what terms he could for the recovery of his dominions.
Maximilian III Joseph (1745–1777), by the Treaty of Füssen signed on 22 April 1745, obtained the restitution of his dominions in return for a formal acknowledgment of the Pragmatic Sanction.
He was a man of enlightenment, did much to encourage agriculture, industries and the exploitation of the mineral wealth of the country, founded the Academy of Sciences at Munich, and abolished the Jesuit censorship of the press.
So great an accession of strength to a neighbouring state, whose ambition she had so recently had just reason to fear, proved intolerable to Austria, which laid claim to a number of lordships —forming one-third of the whole Bavarian inheritance – as lapsed fiefs of the Bohemian, Austrian, and imperial crowns.
These were at once occupied by Austrian troops, with the secret consent of Charles Theodore himself, who was without legitimate heirs, and wished to obtain from the emperor the elevation of his natural children to the status of princes of the Empire.
The funds of the suppressed order of Jesus, which Maximilian Joseph had destined for the reform of the educational system of the country, were used to endow a province of the knights of St John of Jerusalem, for the purpose of combating the enemies of the faith.
The government was inspired by the narrowest clericalism, which culminated in the attempt to withdraw the Bavarian bishops from the jurisdiction of the great German metropolitans and place them directly under that of the pope.
Charles Theodore, who had done nothing to prevent wars or to resist the invasion, fled to Saxony, leaving a regency, the members of which signed a convention with Moreau, by which he granted an armistice in return for a heavy contribution (7 September 1796).Between the French and the Austrians, Bavaria was now in a bad situation.
Bavarian troops under General Karl Philipp von Wrede fought the Austrians at Iglau in Bohemia, which contributed to the simultaneous French victory at Austerlitz on 2 December 1805.
In the war of 1805, in accordance with a treaty of alliance signed at Würzburg on 23 September, Bavarian troops, for the first time since the days of Charles VII, fought side by side with the French, and by the Treaty of Pressburg, signed on 26 December, the Prince-Bishopric of Eichstätt, the Margravate of Burgau, the Lordship of Vorarlberg, the countships of Hohenems and Königsegg-Rothenfels, the lordships of Argen and Tettnang, and the city of Lindau with its territory were to be added to Bavaria.
From 1 January 1806, the Bavarian royal title initially read: "By the grace of God, King of Bavaria, Archpalatine Count of the Holy Roman Empire, Archtruchsess and Elector."