Not much is known of Sabah's early prehistory. Archeological finds are rare but it must be presumed that as early as 40,000 years ago modern man has already roamed the jungles of North Borneo.

By the 9th century AD., Sabah, then under various chieftains, traded with China and later the Spanish and Portuguese. During the 15th century, 

Sabah was a vassal of the Sultan of Brunei. In 1521, Ferdinand Magellan’s ships sailed into Brunei Bay and later repaired their vessels in Banggi and Balambangan islands in the very north of Sabah. In 1704, the Sultan of Brunei ceded the lands east of Marudu Bay to the Sultan of Sulu, while the west coast remained under his rule.

The Sultans of Brunei and Sulu exercised a nominal control over north Borneo, especially the coasts, while headhunters roamed the forests and pirates infested the seas. The headhunters were Kadazandusun, as well as Murut tribesmen, and of the two the Kadazandusun were the first to give up headhunting. The pirates were Illanun, Iranum, Balanini, Obian, Bajau and Suluk living in the Southern Philippines and on islands off the coast of North Borneo. Their vessels were of large size, mostly out-triggered, measuring approximately ninety feet long and heavily armed. In Sabah, their strongest lairs were in Marudu Bay and the Tunku Island near present day Kota Kinabalu.

In 1685 the first Englishman visited Sabah. It was Captain Cowley, and he visited the islands on the northern end of Borneo (Banggi, Balambangan). 

In the 1760’s Alexander Dalrymple and James Rennell came to Borneo and mentioned Sabah.

In 1773 the East India Company founded a trading post on Balambangan Island, but two years later the settlement was attacked and destroyed by pirates. 

It was not until Raja Brooke of Sarawak, with his personal contacts to the Sultan of Brunei, persuaded the Government to suppress piracy and in 1846 the Sultan of Brunei ceded Labuan Island off Sabah's south-west coast to serve as a base for the anti-piracy operations of the British. The last pirate stronghold in Sabah, at Tunku Islands, was destroyed in 1879.