At the outset of World War II in September 1939, Denmark declared itself neutral. For most of the war, the country was a protectorate and then an occupied territory of Germany. The decision to occupy Denmark was taken in Berlin on 17 December 1939. On 9 April 1940, Germany occupied Denmark in Operation Weserübung. The Danish government and king functioned as relatively normal in a de facto protectorate over the country until 29 August 1943, when Germany placed Denmark under direct military occupation, which lasted until the Allied victory on 5 May 1945. Contrary to the situation in other countries under German occupation, most Danish institutions continued to function relatively normally until 1945. Both the Danish government and king remained in the country in an uneasy relationship between a democratic and a totalitarian system until the Danish government stepped down in a protest against German demands to institute the death penalty for sabotage.
Just over 3,000 Danes died as a direct result of the occupation. A further 2,000 volunteers of Free Corps Denmark and Waffen SS, of which most originated from the German minority of southern Denmark, died fighting on the Eastern Front while 1,072 merchant sailors died in Allied service. Overall, this represents a very low mortality rate when compared to other occupied countries and most belligerent countries. Some Danes chose to collaborate during the occupation by joining the National Socialist Workers' Party of Denmark, Schalburg Corps, HIPO Corps and Peter Group (often with considerable overlap between the participants of the different groups). The National Socialist Workers' Party of Denmark participated in the 1943 Danish Folketing election, but despite significant support from Germany it only received 2.1% of the votes.
A resistance movement developed over the course of the war, and most Danish Jews were rescued and sent to neutral Sweden in 1943 when German authorities ordered their internment as part of the Holocaust.