By the end of 17th century, Brunei subsequently entered a period of decline brought on by internal strife over royal succession, colonial expansion of European powers, and piracy.[5] The empire lost much of its territory due to the arrival of the western powers such as Spanish in the Philippines, Dutch in southern Borneo and the British in Labuan, Sarawak and North Borneo. Sultan Hashim Jalilul Alam Aqamaddin later appealed to the British to stop further encroachment in 1888.[25] In the same year British signed a "Treaty of Protection" and made Brunei a British protectorate,[5] until 1984 when it gained independence.[23][26]