Singapore was founded as a British trading colony in 1819. It joined the Malaysian Federation in 1963 but separated two years later and became independent. It subsequently became one of the world's most prosperous countries with strong international trading links (its port is the world's busiest in terms of tonnage handled) and with per capita GDP equal to that of the leading nations of Western Europe.
The first records of Singapore's existence are in Chinese texts from the 3rd century AD. The island was an outpost of the Sumatran Srivijaya empire and originally bore the Javanese name Temasek. Temasek rose to become a significant trading city, but subsequently declined. There are few remnants of old Temasek in Singapore, but archaeologists in Singapore have uncovered evidence of the civilization, as well as other settlements. Between the 16th and early 19th centuries, Singapore was a part of the Sultanate of Johore. During the Malay-Portugal wars in 1617, Singapore was set ablaze by Portuguese troops.
In 1819, Sir Thomas Stamford Raffles, an official with the British East India Company, signed a treaty with the Sultan of Johore. He also established Singapore as a trading post and settlement, which saw instant growth and immigration from various ethnic groups. Singapore was later made a crown colony by Britain in 1867. After a series of colonial territorial expansions, the British Empire soon raised Singapore's status to that of an entrepot town, due to its strategic location along the busy shipping routes connecting Europe to China.
During World War II, the Imperial Japanese Army invaded Malaya and the surrounding region in the Battle of Malaya, which culminated in the Battle of Singapore. The British were unprepared and swiftly defeated, despite having more troops. They surrendered to the Japanese on 15 February 1942. The Japanese renamed Singapore as Syonan-to, Japanese for "Light of the South", and occupied it until the British arrived to repossess the island a month after the Japanese surrender to the United States in September 1945.
Singapore became a self-governing state in 1959 with Yusof bin Ishak as its first head of state and Lee Kuan Yew from the People's Action Party (PAP) as its first Prime Minister, after the 1959 elections. The Merger Referendum passed in 1962 and led to Singapore joining the Federation of Malaysia along with Malaya, Sabah and Sarawak as a state with autonomous powers in September 1963. Singapore was expelled from the federation on 7 August 1965 after heated ideological conflict developed between the state government formed by PAP and the Federal government in Kuala Lumpur. It gained official sovereignty two days later on 9 August 1965, which later became Singapore's National Day. Malaysia was the first country to recognise it as an independent nation.
The fledgling nation had to become self-sufficient, and faced problems including mass unemployment, housing shortages and lack of land and natural resources such as petroleum. During Lee Kuan Yew's term as prime minister from 1959 to 1990, his administration immediately curbed unemployment, raised the standard of living and implemented a large-scale public housing programme. The country economic infrastructure was developed, the threat of racial tension was eliminated and an independent national defence system was created. Singapore evolved from a developing nation to first world status towards the end of the 20th century.
In 1990, Goh Chok Tong succeeded Lee as Prime Minister. During his tenure, the country tackled the economic impacts of the 1997 Asian financial crisis and the 2003 SARS outbreak, as well as terrorist threats posed by the Jemaah Islamiah (JI) post-September 11 and the Bali bombings. In 2004 Lee Hsien Loong, the eldest son of Lee Kuan Yew, became the third prime minister.