According to oral history and medieval commentaries, Shehe Mvita superseded the dynasty of Mwana Mkisi and established his own town on Mombasa Island. The ancient history associated with Shehe Mvita and the founding of an urban settlement on Mombasa Island is still linked to present-day peoples living in Mombasa. The Thenashara Taifa (or Twelve Nations) Swahili lineages recount this ancient history today and are the keepers of local Swahili traditions. Even though today Mombasa is a very heterogeneous cultural mix, families associated with the Twelve Nations are still considered the original inhabitants of the city.
Most of the early information on Mombasa comes from Portuguese chroniclers writing in the 16th century. The famous Moroccan scholar and traveller Ibn Battuta did visit Mombasa in 1331 on his travels on the eastern coast of Africa and made some mention of the city, although he only stayed one night. He noted that the people of Mombasa were Shãfi'i Muslims, "a religious people, trustworthy and righteous. Their mosques are made of wood, expertly built."
The exact founding date of the city is unknown, but it has a long history. Kenyan school history books place the founding of Mombasa as 900 A.D. It must have been already a prosperous trading town in the 12th century, as the Arab geographer Al Idrisi mentions it in 1151.
During the pre-modern period, Mombasa was an important centre for the trade in spices, gold, and ivory. Its trade links reached as far as India and China and oral historians today can still recall this period of local history. Throughout the early modern period, Mombasa was a key node in the complex and far reaching Indian Ocean trading networks, its key exports then were ivory, millet, sesamum and coconuts.
In the late pre-colonial period (late 19th century), it was the metropolis of a plantation society, which became dependent on slave labour (sources contradict whether the city was ever an important place for exporting slaves) but ivory caravans remained a major source of economic prosperity. Mombasa became the major port city of pre-colonial Kenya in the Middle Ages and was used to trade with other African port cities, Persia, Arab traders, Yemen India and China. 15th century Portuguese voyager Duarte Barbosa claimed, "[Mombasa] is a place of great traffic and has a good harbour in which there are always moored small craft of many kinds and also great ships, both of which are bound from Sofala and others which come from Cambay and Melinde and others which sail to the island of Zanzibar." Vasco da Gama was the first known European to visit Mombasa, receiving a chilly reception in 1498. Two years later, the town was sacked by the Portuguese. In 1502, the sultanate became independent from Kilwa Kisiwani and was renamed as Mvita (in Swahili) or Manbasa (Arabic). Portugal attacked the city again in 1528, and built Fort Jesus in 1593 in an attempt to colonise, from which time it was governed by a Captain-major.
In 1638, it formally became a Portuguese colony (subordinated to Goa, as a stronghold on the route to Portuguese India). In 1698, the town came under suzerainty of the Sultanate of Oman, but it became subordinate to Zanzibar, prompting regular local rebellions. Oman appointed three consecutive Governors (Wali in Arabic, Liwali in Swahili):
- 12 December 1698–December 1698: Imam Sa'if ibn Sultan
- December 1698–1728: Nasr ibn Abdallah al-Mazru'i
- 1728–12 March 1728: Shaykh Rumba
Next, Mombasa returned to Portuguese rule by captain-major Álvaro Caetano de Melo Castro (12 March 1728–21 September 1729), then four new Omani Liwali until 1746, when the last of them made it independent again (disputed by Oman), as the first of its recorded Sultans:
- 1746–1755: 'Ali ibn Uthman al-Mazru'i
- 1755–1773: Masud ibn Nasr al-Mazru'i
- 1773–1782: Abdallah ibn Muhammad al-Mazru'i
- 1782–1811: Ahmad ibn Muhammad al-Mazru'i (born 17–died 1814)
- 1812–1823: 'Abdallah ibn Ahmad al-Mazru'i (died 1823)
- 1823–1826: Sulayman ibn 'Ali al-Mazru'i
From 9 February 1824 to 25 July 1826, there was a British protectorate over Mombasa, represented by Governors. Omani rule was restored in 1826; seven liwalis where appointed. On 24 June 1837, it was nominally annexed by sultan of Zanzibar and Muscat Sayyid Said bin Sultan. On 25 May 1887, its administration was relinquished to the British East Africa Association (see Kenya). The sultan formally presented the town in 1898 to the British. It soon became the capital of the British East Africa Protectorate and is the sea terminal of the Uganda Railway, which was started in 1896. Many workers were brought in from British India to build the railway, and the city's fortunes revived. On 1 July 1895, it became part of Britain's Kenya protectorate (the coastal strip nominally under Zanzibari sovereignty).
Mombasa became the capital of the coastal Protectorate of Kenya in 1920. On December 12, 1963 it became part newly independent Kenya. On 28 November 2002, a suicide car bomb exploded at the Israeli-owned beachfront Paradise Hotel, killing three Israelis and ten Kenyans. About 20 minutes earlier, an unsuccessful attempt was made to shoot down an Arkia Israel Airlines Boeing 757 chartered tourist plane taking off from nearby Moi International Airport using surface-to-air missiles; nobody was hurt on the plane, which landed safely in Tel Aviv. The main suspect for both attacks is al Qaeda (see Kenyan hotel bombing).