From Wikipedia
The eastern seaboard of Borneo had been charted (though never settled) by the Portuguese in the early 16th century. The area of today's Sarawak was known to Portuguese cartographers as Cerava. Sawarak had been a loosely governed territory under the control of Brunei Sultanate in the early 19th century, although in the early 17th century Sarawak had her own first and the last Sultan, Sultan Tengah. During the reign of Pangeran Indera Mahkota in 19th century, Sawarak was in chaos. Sultan Omar Ali Saifuddin II (1827-1852) the Sultan of Brunei, ordered Pangeran Muda Hashim in 1839 to restore order and it was during this time that James Brooke arrived in Sarawak. Pangeran Muda Hashim initially requested for assistance but James Brooke refused. In 1841, James Brooke paid another visit to Sarawak and this time he agreed to assist. Pangeran Muda Hashim signed a treaty in 1841 surrendering Sarawak and Sinian to James Brooke. Threafter, on 24 September 1841, Pangeran Muda Hashim bestowed the title Governor to James Brooke. He effectively became the Rajah of Sarawk and founded the White Rajah Dynasty of Sarawak, later extending his administration through an agreement with the Sultan of Brunei.
Brooke was appointed Rajah by the Sultan of Brunie on August 18, 1842; originally this territory was just western end of later Sarawak, around Kuching. He ruled Sarawak until his death in 1868. His nephew Charles Antoni Johnson Brooke became Rajah after his death; he was succeeded on his death in 1917 by his son, Charles Vyner Brooke, with a provision that Charles should rule in consultation with his brother Bertram Brooke. The territory was greatly expaned under the White Rajahs, mostly at the expenses of areas nominally under the control of Brunei. In practice Brunei had only controlled strategic river and coastal forts in much of the lost territory, and so most of gain was at the expense of Muslim warlords and of the de facto independence of local tribes.
The Brooke dynasty ruled Sarawak for hundred years and became famous as the "White Rajahs", accorded a status within the British Empire similar to that of the rulers of Indian princely states. In contrast to many other areas of the empire, however, the Brooke family was intent on a policy paternalism to protect the indigenous population against exploitation. They governed with the aid of the Muslim Malay and enlisted the Ibans and other "Dayak" as a contigent militia. they also encouraged the immigration of Chinese merchants but forbad the Chinise to settle outside of towns in order to minimize the impact on the Dayak way of life. They also established the Sarawak Museum, the first museum in Borneo.
In the early part 1941 preparations were afoot to introduce a new constitution, designed to limit the power of the Rajah and give the people of Sarawak a greater say in government. While the intention was clearly admirable, the draft constitution contained defects and improprieties, not least by reason of secret agreement drawn up between Charles Vyner Brooke and his top government officials, by which he was to be financially compensated for his gesture out of the treasury funds.
Japan invaded Sarawak and occupied the island on Borneo in 1941, occupying Miri on December 16 and Kuching on December 24, and held it for the duration of World War II until the area secured by Australian forces in 1945. The Rajah formally ceded sovereignty to the British Crown on July 1, 1946, under pressure from his wife among others. I addition the British Government offered a healthy pension to sweeten the negotiations. His nephew Anthony Brooke continued to claim sovereignty as Rajah of Sarawak.
After the end of the Second World War, Anthony Brooke then apposed the cession of the Rajah's territory to the British Crown, and was associated with anti-secessionist groups in Sarawak. Anthony was banished from the country. He was allowed to return only seventeen years later, when Sarawak became part of the Federation of Malaysia. Sarawak became a British Colony (formerly an independent state under British protection) in July 1946, but Brooke's campaign continued. The Malays in particular resisted the cession to Britain, dramatically assassinating the first British governor.
Sarawak was officially granted independence on July 22, 1963, and was admitted into the federation of Malaysia on September 16,1963 to the initial opposition from parts of the population. Sarawak was also a flashpoint during the Indonesian Confrontation between 1962 and 1966.