After the disastrous defeat of the Prussian Army at the Battle of Jena-Auerstedt in 1806, Napoleon occupied Berlin and had the officials of the Prussian General Directory swear an oath of allegiance to him, while King Frederick William III and his consort Louise fled via Königsberg and the Curonian Spit to Memel. The French troops immediately took up pursuit but were delayed in the Battle of Eylau on 9 February 1807 by an East Prussian contingent under General Anton Wilhelm von L'Estocq. Napoleon had to stay at the Finckenstein Palace, but in May, after a siege of 75 days, his troops led by Marshal François Joseph Lefebvre were able to capture the city Danzig, which had been tenaciously defended by General Count Friedrich Adolf von Kalkreuth. On 14 June, Napoleon ended the War of the Fourth Coalition with his victory at the Battle of Friedland. Frederick William and Queen Louise met with Napoleon for peace negotiations, and on 9 July the Prussian king signed the Treaty of Tilsit.