A major battleground, Burma was devastated during the Second World War. By March 1942, within months after they entered the war, Japanese troops had advanced on Rangoon and the British administration had collapsed. A Burmese Executive Administration headed by Baw Maw was established by the Japanese in August 1942. Beginning in late 1944, allied troops launched a series of offensives that led to the end of Japanese rule in July 1945. However, the battles were intense with much of Burma laid waste by the fighting.
Although many Burmese fought initially for the Japanese, some Burmese, mostly from the ethnic minorities, also served in the British Burma Army. The Burma Independence Army and the Arakan National Army fought with the Japanese from 1942–1944, but switched allegiance to the Allied side in 1945.
Following the World War II, Aung San negotiated the Panglong Agreement with ethnic leaders that guaranteed the independence of Burma as a unified state. In 1947, Aung San became Deputy Chairman of the Executive Council of Burma, a transitional government. But in July 1947, political rivals backed by the British assassinated Aung San and several cabinet members.
On 4 January 1948, the nation became an independent republic, named the Union of Burma, with Sao Shwe Thaik as its first President and U Nu as its first Prime Minister. Unlike most other former British colonies and overseas territories, it did not become a member of the Commonwealth.