The Federated Malay States (FMS, , Jawi: ) was a federation of four protected states in the Malay Peninsula—Selangor, Perak, Negeri Sembilan and Pahang—established by the British government in 1896, which lasted until 1946, when they, together with two of the former Straits Settlements (Malacca and Penang) and the Unfederated Malay States, formed the Malayan Union. Two years later, the Union became the Federation of Malaya, which achieved independence in 1957, and finally Malaysia in 1963 with the inclusion of North Borneo (present-day Sabah), Sarawak and Singapore. Real power in the FMS and its constituent states rested with the four local British Residents and the Resident-General, the discretionary powers of the local sultans being essentially reduced to matters "touching Malay Religion and Customs". The federation, along with the other Malay states and British possessions of the peninsula, was overrun and occupied by the Japanese during World War II. After the liberation of Malaya following the Japanese surrender, the federation was not restored, but the federal form of government was retained as the principal model for consolidating the separate States as an independent Federation of Malaya and the Federation's later evolution into Malaysia. Formation and power structure On 20 January 1874, Sir Andrew Clarke, governor of the Straits Settlements, concluded with the Sultan of Perak the treaty of Pangkor whereby the Sultan agreed to "receive and provide a suitable residence for a British Officer to be called Resident, who shall be accredited to his court, and whose advice must be asked and acted upon on all questions other than those touching Malay Religion and Customs". The residency system was extended the same year to the states of Selangor and Negri Sembilan, and in 1888 to Pahang. To promote greater administrative efficiency, these four states were brought together in 1895-1896 to form the Federated Malay States. This structure was highly centralized, real power resting in the hands of the agents of the British Government, at first called the Resident-General, and later the Chief Secretary. The British established the Federal Council in 1898 to administer the Federation. It was headed by the High Commissioner (The Governor of the Straits Settlement), assisted by the Resident-General, the Sultans, the four state Residents and four nominated unofficial members. This structure remained until the Japanese invaded Malaya on 8 December 1941. The sultans and First Durbar Although the Resident-General was the real administrator of the federation, each