In the 19th century, following three Anglo-Burmese Wars, Burma was colonized by Britain. On 1 April 1937, Burma became a separately administered colony of Great Britain and Ba Maw the first Prime Minister and Premier of Burma. Ba Maw was an outspoken advocate for Burmese self-rule and he opposed the participation of Great Britain, and by extension Burma, in World War II. He resigned from the Legislative Assembly and was arrested for sedition. In 1940, before Japan formally entered the Second World War, Aung San formed the Burma Independence Army in Japan.
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 Ba 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 National Army and the Arakan National Army fought with the Japanese from 1942–44, but switched allegiance to the Allied side in 1945.
Following 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 at 4.20 am, 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.