At the Battle of Kempen Heath Hesse-Cassel, with the support of French and Weimar troops, dealt the Imperial forces a heavy defeat. In the wake of this defeat, large areas in the north of the Electorate, including the Duchy of Berg, and even parts of the neutral Duchy of Jülich fell under the occupation of Hesse-Cassel. Inspired by military and diplomatic successes in the Rhineland and Westphalia, Landgravine Amalia Elisabeth of Hesse-Cassel felt strong enough to take up the fight for the Marburg inheritance in 1644. She had the "Hauptakkord" treaty of 1627, in which Hesse-Cassel had forfeited Upper Hesse, invalidated by a subsequent legal ruling and, at the end of 1645, sent her battle-hardened troops led by John of Geyso towards Marburg. After a short siege of Marburg and Butzbach and their surrender, the majority of Upper Hesse fell again under the rule of Kassel in early 1646. In 1647, an imperial army under the command of General Melander, who had recently switched sides from Cassel to Darmstadt, succeeded in recovering the town of Marburg - but not its castle. But because the town of Darmstadt and the Upper County was attacked in turn by French troops under the command of Marshal Turenne shortly thereafter, this success was short-lived. By the end of 1647, troops from Cassel had re-occupied the majority of Lower and Upper Hesse and the Lower County of Katzenelnbogen. In early 1648, Melander's troops withdrew from Marburg. The Hessian War was finally permanently settled by negotiations, that took place in parallel with the Westphalian Peace Congress mediated by Duke Ernest of Saxe-Gotha and which resulted in a unification and peace treaty that was sealed in April 1648, ahead of the Treaty of Westphalia itself. Before the Westphalian Peace Treaty, Cassel fought one last time against the imperial side, winning the Battle of Wevelinghoven in the Rhineland, together with other Protestant troops. Darmstadt, however, was not involved in this battle. Under the Unification Treaty between Cassel and Darmstadt, Upper Hesse was permanently divided. Darmstadt had to give up a significant part of Upper Hesse to Cassel, not least Marburg and other occupied territories, including the Lower County of Katzenelnbogen and the Barony of Schmalkalden.