The British signed treaties of protection with Malay rulers from 1874 to 1930. In 1896 some of these states were grouped together as the federated Malay States. Malaya was occupied by the Japanese from 1942 to 1945. All the Malay states, together with the Straits Settlements except for Singapore, were incorporated into a new federation in 1948. This was the basis on which Malaya achieved independence in 1957. In 1963 Malaya joined with Singapore (which seceded in 1965), North Borneo, and Sarawak to form Malaysia.