In 1865, the American Consul for Brunei, Claude Lee Moses obtained a lease over North Borneo. The lease ownership was passed to an American company which tried to set up a post in what is today Kimanis. That also turned out to be a failure and was abandoned. The lease was then sold to Baron von Overbeck, the Austrian Consul in Hong Kong which he then transferred to Alfred Dent who in 1882 formed the British North Borneo Company to develop the colony. The capital was first established in Kudat, then transfered to Sandakan. North Borneo became a protectorate of Great Britain in 1888 but administration and control over the colony remained in the hands of the Company ruled until 1942 when the Japanese invaded. There were of course resistance to the company's rule, including by Mat Salleh in the late 1890s and the Muruts in the early 1900s.
The Japanese occupation between 1942 and 1945 was brutal and this was when the infamous Death Marches by British and Allied soldiers forced by the Japanese took place. British Military Administration took over when the Japanese surrendered and in 1946, North Borneo became a British Crown Colony. Jesselton (now Kota Kinabalu), which suffered Allied bombing, was rebuilt and chosen to replace Sandakan as the capital.
On September 16, 1963, North Borneo together with Malaya, Sarawak and Singapore formed the Federation of Malaysia and from then on it became known as Sabah.