The coast around today's Kota Kinabalu was home to Bajau fishing villages and Kadazan-Dusun farming communities, with traders from Brunei and the Sulu islands. In 1882 the British North Borneo Chartered Company began to rule the territory of North Borneo.
The Company first set up a trading post on Gaya Island, which was burned in 1897 during the revolt of Mat Salleh, a local leader who resisted Company rule. A new town was founded on the mainland in 1899 and named Jesselton, after Sir Charles Jessel, a director of the Company. A railway soon linked it with Beaufort and the interior.
During the Japanese occupation (1942–1945) the town was called Api. In October 1943 local Chinese and Indigenous fighters led by Albert Kwok rose against the occupiers in the Jesselton Revolt (Double Tenth); it was crushed and many were executed. Allied bombing in 1945 left almost the whole town in ruins — the Atkinson Clock Tower of 1905 is one of the few buildings that survived.
After the war North Borneo became a British Crown Colony (1946), and Jesselton replaced the destroyed Sandakan as its capital. On 16 September 1963 North Borneo, renamed Sabah, joined Malaysia. Jesselton was renamed Kota Kinabalu — "Kinabalu City", after the mountain — in 1968, and received city status in 2000.