The German Army invaded France on 10 May 1940, and in just over ten days their rapid advance, led by three panzer corps, had left three French field armies, Belgian forces and the British Expeditionary Force with their backs to the sea, trapped along the northern coast of France. General Gort realised that evacuation was the only option, and so began a chaotic withdrawal towards the port of Dunkirk.
While the Luftwaffe continued to attack pockets of Allied forces, the German ground forces were ordered to halt their advance on 22 May. These orders were changed four days later, but these crucial four days of inaction allowed the Allies time to retreat into Dunkirk and prepare a defensive perimeter.
The fighting during the last days of May was desperate, with the remnants of the French First Army surrounded at Lille, holding off seven German divisions until finally forced to surrender, and the Belgian Army forced to capitulate to the east of Dunkirk. Though the cost was devastatingly high, Dunkirk was held long enough for over 300,000 Allied troops to be evacuated back to England, with the remainder of the rearguard of French troops surrendering on 4 June.