On 8 December 1941, in concert with the attack on Pearl Harbor, Japanese forces invaded and occupied Thailand. King Ananda was away from the country, as he had returned to Switzerland to complete his studies, and Pridi Phanomyong served as regent in his absence. From 24 January 1942, occupied Thailand became a formal ally of the Empire of Japan and a member of the Axis. Under Plaek Pibunsonggram, Thailand declared war on the Allied powers. The regent refused to sign the declaration and it was thus legally invalid. Many members of the Thai government, including the Siamese embassy in Japan, acted as "de facto" spies in the Seri Thai underground on the side of the Allies, funnelling secret information to British intelligence and the US Office of Strategic Services. By 1944, it was apparent that Japan was going to lose the war. Bangkok suffered heavily from the Allied bombing raids. These, plus economic hardships, made the war and the government of Plaek Pibunsonggram very unpopular. In July, Plaek Pibunsonggram was ousted by the Seri Thai-infiltrated government. The National Assembly reconvened and appointed the liberal lawyer Khuang Aphaiwong prime minister. Japan surrendered on 15 August 1945, and Allied military responsibility for Thailand fell to Britain.