Following World War II, public pressure for independence increased. The British Colony of Ceylon achieved independence on 4 February 1948, with an amended constitution taking effect on the same date. Independence was granted under the Ceylon Independence Act 1947. Military treaties with the United Kingdom preserved intact British air and sea bases in the country; British officers also continued to fill most of the upper ranks of the Army. Don Senanayake became the first Prime Minister of Ceylon. Later in 1948, when Ceylon applied for United Nations membership, the Soviet Union vetoed the application. This was partly because the Soviet Union believed that the Ceylon was only nominally independent, and the British still exercised control over it because the white, educated elite had control of the government. In 1949, with the concurrence of the leaders of the Sri Lankan Tamils, the UNP government disenfranchised the Indian Tamil plantation workers. In 1950, Ceylon became one of the original members of the Colombo Plan, and remains a member as Sri Lanka.
Don Senanayake died in 1952 after a stroke and he was succeeded by his son Dudley. However, in 1953 – following a massive general strike or 'Hartal' by the leftist parties against the UNP – Dudley Senanayake resigned. He was followed by John Kotelawala, a senior politician and an uncle of Dudley. Kotelawala did not have the personal prestige or the political acumen of D. S. Senanayake. He brought to the fore the issue of national languages that D. S. Senanayake had suspended. The Queen of Ceylon, Elizabeth II, toured the island in 1954 from 10–21 April. (She also visited in 1981 (21–25 October) after the country became a republic.)
In 1956 the UNP was defeated at elections by the Mahajana Eksath Peramuna, which included the Sri Lanka Freedom Party (SLFP) led by Solomon Bandaranaike and the Viplavakari Lanka Sama Samaja Party of Philip Gunawardena. Bandaranaike was a politician who had fostered the Sinhala nationalist lobby since the 1930s. He replaced English with Sinhalese as the official language. He was the chief Sinhalese spokesmen who attempted to counter the communal politics unleashed by G. G. Ponnambalam. The bill was known as the Sinhala Only Bill, and also made Sinhalese the language taught in schools and universities. This caused Tamil riots, as they spoke the Tamil language and it had not been recognised as an official language. These riots culminated in the assassination of the prime minister, Bandaranaike. His widow, Sirimavo, succeeded her husband as leader of the SLFP and was elected as the world's first female prime minister. In 1957 British bases were removed and Ceylon officially became a "non-aligned" country. The Paddy Lands Act, the brainchild of Philip Gunawardena, was passed, giving those working the land greater rights vis-a-vis absentee landlords.
Elections in July saw Sirimavo Bandaranaike become the world's first elected female head of government. Her government avoided further confrontations with the Tamils, but the anti-communist policies of the United States Government led to a cut-off of United States aid and a growing economic crisis. After an attempted coup d'état by mainly non-Buddhist right-wing army and police officers intent on bringing the UNP back to power, Bandaranaike nationalised the oil companies. This led to a boycott of the country by the oil cartels, which was broken with aid from the Kansas Oil Producers Co-operative.
In 1962, under the SLFP's radical policies, many Western business assets were nationalised. This caused disputes with the United States and the United Kingdom over compensation for seized assets. Such policies led to a temporary decline in SLFP power, and the UNP gained seats in Congress. However, by 1970, the SLFP were once again the dominant power.