Ferdinand Maria (31 October 1636 – 26 May 1679) was a Wittelsbach ruler of Bavaria and a prince-elector of the Holy Roman Empire from 1651 to 1679. The Elector modernized the army and introduced Bavaria's first government code. Besides encouraging agriculture and industry, he also improved building and restoration works on churches and monasteries since the damage caused during the Thirty Years' War.
Born during the reign of his father, he was known as the Electoral Prince from birth. Through his mother, he was a first cousin of Queen Mariana of Spain as well as Leopold I, Holy Roman Emperor.
Still a minor when he succeeded his father in 1651, his mother became his guardian and his uncle, Albert VI of Bavaria served as Prince Regent of Bavaria for three years.
The marriage of his eldest daughter Maria Anna Victoria and her cousin le Grand Dauphin in 1680 was the outcome of the Bavarian alliance with France. Ferdinand Maria was the great grandfather of the future French monarch Louis XV.
Ferdinand Maria modernized the Bavarian Army and introduced the first Bavarian local government code. The Elector 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. In 1669, moreover, he again called a meeting of the diet, which had been suspended since 1612. At the end of his reign he left the electorate with a very wealthy treasury.
The Theatine Church, Munich was built from 1663 onwards as a gesture of thanks for the birth of the long-awaited heir to the Bavarian crown, Prince Maximilian II Emanuel. After that in 1664, Ferdinand Maria and his wife commissioned the building of the Baroque styleNymphenburg Palace near Munich based on the designs of Italian architect Agostino Barelli.
Lake Starnberg was purchased by Ferdinand Maria from the Horwarth family and it became the venue of numerous festivities of the court with the famous fleet of Venetian Gondolas. On the lake's shores, he ordered the construction of Berg Castle in 1676.
The castle was used for festivities there and later reached its zenith when it became the scene of spectacular entertainments and hunts under the rule of his successors, Maximilian Emanuel and Emperor Charles VII. For the Munich Residenz, Ferdinand Maria ordered the creation of the Papal Rooms.