In 1246, the young Louis supported his brother-in-law King Conrad IV of Germany against the usurpation of Heinrich Raspe. In 1251, Louis was at war again against the bishop of Regensburg. Louis succeeded his father Otto as Duke of Bavaria in 1253. When the Wittelsbach country was divided in 1255 among Otto's sons, Louis received the Palatinate and Upper Bavaria making him the duke of Upper Bavaria, while his brother duke Henry XIII of Bavaria received Lower Bavaria making him the duke of Lower Bavaria. This partition was against the law and therefore caused the anger of the bishops in Bavaria who later allied themselves with king Ottokar II of Bohemia in 1257. During the German interregnum, after King William's death in 1256, Louis supported King Richard of Cornwall. In August 1257 King Ottokar finally invaded Bavaria, but Louis and Henry managed to repulse the attack. It was one of the rare concerted and harmonious actions of the two brothers, who often argued. The main residences of Louis were at Alter Hof located at the very north-eastern part of Munich and Heidelberg Castle. As one of the Prince-electors of the empire, he was strongly involved in the royal elections for forty years. Together with his brother, Louis also aided his young Hohenstaufen nephew Conradin in his duchy of Swabia, but it was not possible to enforce Conradin's election as German king. As a result of his support for the Hohenstaufen, Louis was banned by the pope in 1266. In 1267 when his nephew crossed the Alps with an army, Louis accompanied Conradin only to Verona. After the young prince's execution in Naples in 1268, Louis inherited some of Conradin's possessions in Swabia and supported the election of the HabsburgRudolph I against Ottokar II in 1273. On 26 August 1278, the armies of Rudolph and Louis met Ottokar's forces on the banks of the River March in the Battle of Dürnkrut and Jedenspeigen where Ottokar was defeated and killed. In 1289, the electoral dignity of Bavaria passed to Bohemia again, but Louis remained an elector as Count Palatine of the Rhine. After Rudolph's death in 1291, Louis could not enforce the election of his Habsburg brother-in-law Albert I against Adolf of Nassau. Louis died at Heidelberg on 2 February 1294. He was succeeded by his eldest surviving son Rudolf I who had Adolf of Nassau as his father-in-law a few months later. Louis was buried in the crypt of Fürstenfeld Abbey.
He had his first wife, Maria of Brabant—a daughter of Henry II, Duke of Brabant and Marie of Hohenstaufen—beheaded in 1256, on suspicion of adultery. Any actual guilt on her part could never be validated. As expiation, Louis founded the Cistercian friary Fürstenfeld Abbey near Munich. Different sources tell varying tales about how this happened: In 1256, Louis had been away from home for an extended time due to his responsibilities as a sovereign in the area of the Rhine. His wife wrote two letters, one to her husband, and another to the count of Kyburg at Hunsrück, a vassal of Louis. Details about the actual content of the second letter vary, but according to the chroniclers, the messenger who carried the letter to Ludwig had been given the wrong one, and Louis came to the conclusion that his wife had a secret love affair. Over time a great many tales of folklore sprang up around Louis' deed, most of them written long after his death: Ballad-mongers embellished the tale into a murderous frenzy during which Louis allegedly not only killed his wife after having ridden home for five days and nights, but also stabbed the messenger who brought him the wrong letter; then upon entering his castle, stabbed his own castellan and a court lady and threw his wife's maid from the battlements, before he massacred his wife either by stabbing her or cutting off her head. Several more restrained chronicles support the account of Marie's execution on 18 January 1256 at Mangoldstein Castle in Donauwörth by ducal decree for alleged adultery, but nothing beyond that.
Later marriages
Louis married his second wife, Anna of Glogau, in 1260. They had the following children: