He was serving as Prime Minister when Nazi Germany attacked on Norway 9 April 1940. Following the German occupation of Norway, German officials demanded that the Government headed by Nygaardsvold capitulate and that the King appoint a government headed by Nazi sympathiser Vidkun Quisling. King Haakon VII stated that he could not comply with the German ultimatum and would rather abdicate than appoint Quisling prime minister. On 7 June 1940, the Norwegian Government-in-exile relocated to London. Nygaardsvold continued as prime minister in exile until the government returned to Norway on 31 May 1945. He resigned on 25 June 1945 when King Haakon appointed Einar Gerhardsen to head an interim government composed of all political parties.