civil war. The territory seems never to have been ceded formally, but the Sulus continued to claim the territory, with Brunei weakened and unable to resist. After the war with the Spanish, the area in northern Borneo began to fall under the influence of the Sulu Sultanate. The seafaring Bajau-Suluk and Illanun people then arrived from the Sulu Archipelago and started settling on the coasts of north and eastern Borneo, many of them were fleeing from the oppression of Spanish colonialism. While the thalassocratic Brunei and Sulu sultanates controlled the western and eastern coasts of Sabah respectively, the interior region remained largely independent from either kingdoms. The Sultanate of Bulungan's influence was limited to the Tawau area, who came under the influence of the Sulu Sultanate before gaining its own rule after the 1878 treaty between the British and Spanish governments. British North Borneo In 1761, Alexander Dalrymple, an officer of the British East India Company, concluded an agreement with the Sultan of Sulu to allow him to set up a trading post for the first time in northern Borneo, although this was to prove a failure. Following the British occupation of Manila in 1763, the British freed the Sultan Alimuddin from Spanish colonisers and allowed him to return to his throne; this was welcomed by the Sulu people and by 1765, Dalrymple managed to obtain the island, having concluded a Treaty of Alliance and Commerce with the Sultan of Sulu by the willing of Sultan Alimuddin as a sign of gratitude for the British aid. A small British factory was then established in 1773 on Balambangan Island, a tiny island situated off the north coast of Borneo. The British saw the island as a suitable location to control the trade route in the East, capable of diverting trade from the Spanish port of Manila and the Dutch port of Batavia especially with its strategic location between the South China Sea and Sulu Sea. But the British abandoned the island two years later when the Sulu pirates began attacking. This forced the British to seek refuge in Brunei in 1774, and to abandon temporarily their attempts to find alternative sites for the factory. Although an attempt was made in 1803 to turn Balambangan into a military station, the British did not re-establish any further trading posts in the region until Stamford Raffles founded Singapore in 1819. In 1846, the island