Life in Sarawak was first recorded at the Niah Caves, as the earliest known human settlement was documented here 40,000 years ago. Indication of trade and interaction with the outside world is evident with the discovery of a series of Tang and Song dynasty ceramics dating from the 8th to 13th century AD in Santubong. During the mid-15th century, the Bruneian Empire established its presence in the coastal regions of Sarawak. There have also been records of the Kuching area documented by the Portugese cartographers during the 16th century, recognising it as Cerava, one of the five great seaports of Borneo.
The birth of the Sultanate of Sarawak was established during the 16th century, and it was a local kingdom that existed for almost 500 years before being reunited with Brunei in 1641. However, by the early 19th century, the Bruneian Empire was in decline, retaining only a tenuous hold along the coastal regions of Sarawak which were otherwise controlled by semi-independent Malay leaders. The discovery of antimony in Kuching led to the increased development in the territory between 1824 and 1830, however the demand of higher taxes by the Brunei Sultanate soon led to civil unrest in the state, a situation that proved too difficult for the Sultanate to handle, leading to the request for aid of British sailor, James Brooke.
Brooke managed to quell the revolt and was rewarded with antimony, property and the governorship of Sarawak, which at that time consisted only of a small area centred on Kuching. This marked the beginning of the rule of the White Rajahs, who set about expanding the territory they had been ceded. With expansion came the need for efficient governance and thus, beginning in 1841, Sarawak was separated into the first of its administrative divisions with currency, the Sarawak dollar, beginning circulation in 1858. By 1912, a total of five divisions had been established in Sarawak, each headed by a Resident.
The Brooke family generally practised a paternalistic form of government with minimal bureaucracy, and had established the oldest state legislative assembly in Malaysia, the advisory Supreme Council, mostly consisting of Malay chiefs, to provide guidance to the Brooke government who were largely unfamiliar with local customs. The historic first General Council meeting took place at Bintulu in 1867.
A similar system relating to matters concerning various Chinese communities was also formed. Members of the local community were encouraged by the Brooke regime to focus on particular functions within the territory: the Ibans and other Dayak people were hired as militia while Malays were primarily administrators. Chinese, both local and immigrant, were mostly employed in plantations, mines and as bureaucrats. Expanding trade led to the formation of the Borneo Company Limited in 1856. The company was, and still is, involved in a wide range of businesses in Sarawak including trade, banking, agriculture, mineral exploration, and development.
Territorial expansion of the Kingdom of Sarawak from 1841 to 1905 played a significant role to the present-day boundaries of the modern state of Sarawak. Between 1853 and 1862, there were a number of uprisings against the Brooke government but all were successfully contained with the aid of local tribes. To guard against future uprisings, a series of forts were constructed to protect Kuching, including Fort Margherita, completed in 1871.
Over the years, the Brooke government established the Sarawak Museum, the oldest museum in Borneo, secured larger territorial areas which would form present day Sarawak, encourage economic growth and development with the discovery of petroleum and its subsequent oil well drilling and the opening of Brooke Dockyard. All this would continue up to the Japanese occupation of Sarawak, which then saw the British withdrawing its air and marine forces to Singapore, and the destruction of oil wells and airfields in Sarawak.
Sarawak was part of the Empire of Japan during the Japanese occupation, and was divided into three provinces during this period. While there were Provincial Governors in place, the Japanese Empire preserved the Brooke administrative structure and appointed the Japanese to important government positions. Following the fall of the Japanese Empire in 1945, Sarawak was placed under British Military Administration and managed by Australian Imperial Forces (AIF) until April 1946.
Lacking the resources to rebuild Sarawak after the war, Charles Vyner Brooke decided to cede Sarawak as British Crown Colony and a Cession Bill was put forth in the Council Negri (now Sarawak State Legislative Assembly), which was debated for three days. The bill was passed on 17 May 1946 with a narrow majority (19 versus 16 votes). This caused hundreds of Malay civil servants to resign in protest, sparking an anti-cession movement and the assassination of the second colonial governor of Sarawak Sir Duncan Stewart. Despite the resistance, Sarawak became a British Crown colony on 1 July 1946.
In 1950 all anti-cession movements in Sarawak ceased after a clamp-down by the colonial government. On 27 May 1961, Tunku Abdul Rahman, the prime minister of the Federation of Malaya, announced a plan to form a greater federation together with Singapore, Sarawak, Sabah and Brunei, to be called Malaysia, and the Cobbold Commission was formed to gauge the support of Sarawak and Sabah for the plan, which found that 80% of the population showed support for the federation. Sarawak was officially granted self-government on 22 July 1963, and formed the federation of Malaysia on 16 September 1963.