The Treaty of Trausnitz, signed at Trausnitz Castle by Frederick the Fair, duke of Austria and Styria, and Louis IV, Holy Roman Emperor, duke of Upper Bavaria, on March 13, 1325 ended the dispute between the two men over the rule of the Holy Roman Empire.
Following the death in 1313 of Henry VII, Holy Roman Emperor, two rival factions elected both Frederick and Louis King of the Romans at separate elections on October 19 and October 20, 1314. A war ensued between their partisans in the Empire.
On September 18, 1322, at the Battle of Mühldorf, Louis decisively defeated Frederick and took him captive to be imprisoned at Trausnitz Castle. This did not end the resistance of Frederick's brother Leopold I, Duke of Austria, who ruled Austria and Styria in his absence, or earn the support of the pope, Pope John XXII, for his claim. In fact, John excommunicated Louis in 1324.
In response to the military pressure from Leopold and the political pressure from John, Louis released Frederick from captivity. In exchange, Frederick agreed to recognize Louis as King of the Romans and to convince his brother Leopold to end his resistance. If he could not do the latter, he agreed to return to captivity.
Frederick failed to convince Leopold to accept Louis as King of the Romans to make peace. True to his word, he submitted to captivity in Munich later that year. Louis, impressed, offered Frederick the rule of the Holy Roman Empire jointly with himself.