During the late 18th and 19th centuries, Great Britain established colonies and protectorates in the area of current Malaysia; these were occupied by Japan from 1942 to 1945. In 1948, the British-ruled territories on the Malay Peninsula formed the Federation of Malaya, which became independent in 1957. Malaysia was formed in 1963 when the former British colonies of Singapore and the East Malaysian states of Sabah and Sarawak on the northern coast of Borneo joined the Federation. The first several years of the country's history were marred by a Communist insurgency, Indonesian confrontation with Malaysia, Philippine claims to Sabah, and Singapore's secession from the Federation in 1965. During the 22-year term of Prime Minister MAHATHIR bin Mohamad (1981-2003), Malaysia was successful in diversifying its economy from dependence on exports of raw materials to expansion in manufacturing, services, and tourism.