On 1 December 1918, the Act of Union, an agreement with Denmark, recognized Iceland as a fully sovereign state, an independent country in personal union with Denmark through a common monarch. The Kingdom of Iceland established its own flag and coat of arms and asked that Denmark represent its foreign affairs and defence interests on its behalf while retaining full control over its foreign affairs and defence. Iceland opened its first Embassy in 1920. The Act would be reviewed in 1940 and could be revoked three years later if agreement to continue it could not be reached.
The German occupation of Denmark on 9 April 1940 severed communications between Iceland and Denmark. As a result, on 10 April, the Althing passed two resolutions investing the Icelandic cabinet with the power of head of state and declaring that Iceland would accept full responsibility for both foreign policy and coastal surveillance. A year later, on 15 May 1941 the Althing adopted a law creating the position of regent for Sveinn Björnsson in order to represent the monarchy. During the first year of World War II, Iceland strictly enforced a position of neutrality and took action against both British and German forces that violated it. On 10 May 1940, Operation Fork was launched by the United Kingdom when military forces sailed into Reykjavík harbour and began an invasion of Iceland. The government of Iceland issued a protest against what it called a "flagrant violation" of Icelandic neutrality. On the day of the invasion, Prime MinisterHermann Jónasson read a radio announcement instructing Icelanders to treat the British troops as guests. The Allied occupation of Iceland lasted until 1941 when the Government of Iceland asked the United States to take over its defence. The defence of Iceland was the United States' first participation in World War II. At its peak, Britain had approximately 25,000 troops stationed in Iceland, all but eliminating unemployment in Reykjavík and other strategically important places. In July 1941, the Althingi adopted the American–Icelandic defence agreement, passing responsibility for Iceland's defence to the United States. As many as 40,000 American soldiers were then stationed on the island, outnumbering the native population of adult men. Following a constitutional referendum in May 1944, Iceland formally became a republic on 17 June 1944. Many Danes felt offended at its timing, as Denmark was still occupied by Germany. The king in Copenhagen, Christian X, nonetheless sent a message of congratulations to the Icelandic people.