But when Prussia, after it turned against the French Empire, was defeated in the Battle of Jena–Auerstedt (October 14, 1806), Frederick William III was forced to temporarily flee to remote Memel. After the Treaties of Tilsit in 1807, Prussia lost about half of its territory, including the land gained from the Second and Third Partitions of Poland (which now fell to the Duchy of Warsaw) and all land west of the Elbe River. France recaptured Prussian-occupied Hanover, including Bremen-Verden. The remainder of the kingdom was occupied by French troops (at Prussia's expense) and the king was obliged to make an alliance with France and join the Continental System.