The earliest known settlement on Singapore was in the second century AD. It was an outpost of the Sumatran Srivijaya empire, named Temasek ('sea town'). Between the 16th and early 19th centuries, it was part of the Sultanate of Johor. In 1613, Portuguese raiders burnt down the settlement and the island sank into obscurity for the next two centuries.

In 1819, Thomas Stamford Raffles arrived and signed a treaty with Sultan Hussein Shah on behalf of the British East India Company to develop the southern part of Singapore as a British trading post. In 1824, the entire island became a British possession under a further treaty with the Sultan and the Temenggong.[12] In 1826, it became part of the Straits Settlements, under the jurisdiction of British India. Singapore became the capital of the Straits Settlements in 1836.[13] Before Raffles arrived, there were around 1,000 people living in Singapore, mostly indigenous, but with around 20-30 Malays and 20-30 Chinese.[14] By 1860, the population exceed 80,000, with over half of the population being Chinese. Many immigrant came to work at rubber plantations, and after the 1870s the island became a global centre for rubber exports.

During World War II, the Imperial Japanese Army invaded Malaya culminating in the Battle of Singapore. The British were defeated, and surrendered on 15 February 1942. British Prime Minister Winston Churchill called this "the worst disaster and largest capitulation in British history".[15] The Sook Ching massacre of ethnic Chinese after the fall of Singapore claimed between 5,000 and 25,000 lives.[16] The Japanese occupied Singapore until the British repossessed it in September 1945 after the Japanese surrender.

Singapore's first general election in 1955 was won by the pro-independence David Marshall, leader of the Labour Front. Demanding complete self-rule he led a delegation to London but was turned down by the British. He resigned when he returned and was replaced by Lim Yew Hock, whose policies convinced Britain to grant Singapore full internal self-government for all matters except defence and foreign affairs.

During the May 1959 elections, the People's Action Party won a landslide victory. Singapore had become an internally self-governing state within the Commonwealth, with Lee Kuan Yew as the first Prime Minister.[19] Governor Sir William Allmond Codrington Goode served as the first Yang di-Pertuan Negara ("Head of State"), and was succeeded by Yusof bin Ishak who in 1965 became the first President of Singapore.[20] During the 1950s Communists, mostly supported by the Chinese-speaking group, with strong ties to the trade unions and Chinese schools, carried out an armed struggle against the state, resulting in the Malayan Emergency and later, the Communist Insurgency War. The 1954 National Service Riots, Chinese middle schools riots and Hock Lee bus riots in Singapore were all linked to the Communists.

On 31 August 1963, Singapore declared independence from Britain and joined with Malaya, Sabah and Sarawak to form the new Federation of Malaysia as the result of the 1962 Merger Referendum. Singaporean leaders joined Malaysia for various reasons. Firstly, as a small country, they did not believe that the British would find it viable for Singapore to become independent by itself. Secondly, they also did not believe that Singapore could survive on its own, due to scarcity of land, water, markets and natural resources. And lastly, the Singapore government wanted the help of the Malaysian government to flush out the Communists. The two years that Singapore spent as part of Malaysia were filled with strife and bitter disagreements. The Malaysians insisted on a pro-Malay society, where Malays were given special Bumiputera rights, which still exist to this day. The Malaysians were also suspicious about Singapore's majority of ethnic Chinese and worried that Singapore's economic clout would shift the centre of power from Kuala Lumpur to Singapore. There were also linguistic and religious issues. The Singaporeans, on the other hand, wanted an equal and meritocratic society, where all citizens were given equal rights. As part of Malaysia, Singapore's economic and social development came to a halt as the Malaysian parliament blocked many bills. Race riots broke out in Singapore in 1964. After much heated ideological conflicts between the two governments, in 1965, the Malaysian parliament voted 126 to 0 to expel Singapore from Malaysia.

Singapore gained independence as the Republic of Singapore (remaining within the British Commonwealth) on 9 August 1965[3] with Yusof bin Ishak as president and Lee Kuan Yew as prime minister. Every one who was present in Singapore on the date of independence was offered Singapore citizenship. In 1967, it helped found the Association of Southeast Asian Nations[24] and in 1970 it joined the Non-aligned movement. In 1990, Goh Chok Tong succeeded Lee as prime minister. During his tenure the country faced the 1997 Asian Financial Crisis, the 2003 SARS outbreak and terrorist threats posed by Jemaah Islamiyah. In 2004, Lee Hsien Loong, the eldest son of Lee Kuan Yew, became the country's third prime minister.