 During the Napoleonic Wars it was spared the infliction of a French occupation through the good offices of King Maximilian I Joseph of Bavaria and his minister Maximilian von Montgelas; Duke Charles II of Mecklenburg-Strelitz declared neutrality in 1806 and joined the Confederation of the Rhine in 1808, however, he withdrew in 1813 on the eve of the German campaign in favor of an alliance against Napoleon.He joined the German Confederation established after the 1815 Congress of Vienna to succeed the dissolved Holy Roman Empire; he and his cousin Frederick Francis I of Mecklenburg-Schwerin both assumed the title of grand duke ("Großherzog von Mecklenburg").Though Grand Duke Frederick William openly rejected the Prussian annexation of the Kingdom of Hanover, the Prussian Army had been aided by soldiers from Mecklenburg-Strelitz in the Austro-Prussian War of 1866.