At the end of the war, the Swedish navy had lost at sea, the Danish army had been defeated in Scania by the Swedes, who in turn had been beaten in Northern Germany by the Brandenburgers. The war and the hostilities ended when Denmark's ally the United Provinces settled with Sweden's ally France and the Swedish king Charles XI married Danish princess Ulrike Eleonora, sister of Christian V. Peace was made on behalf of France with the treaties of Fontainebleau and Lund (Sweden and Denmark- Norway) and Saint-Germain-en-Laye (Sweden and Brandenburg), restoring most of the lost territories to Sweden.