After the fall of the Malacca Sultanate numerous local groups, primarily from Sumatra sought to gain power; the Johor Sultanate and Aceh Sultanate from this island were the most successful. Despite their greatest efforts, these sultanates couldn't re-take the Malacca straight from the Portuguese until 1641 when the Johors did it on the Dutch lead.
After Dutch intervention, their local ally, the Johor Sultanate slowly began taking over numerous small governments in the Malay Peninsula. After the Johors came the Bugis dynasty who slowly took over the Johor lands at the end of the 1600s. More than anything, this led to the fall of the Johors, leading to the intervention of Siam (modern day Thailand), who took much of the Malay Peninsula.
From this point, about 1700 through the end of the 1800s Malaysia was ruthlessly exploited as the land has tin and gold. This led to additional immigrants to the already diverse region, however now most of the immigrants were wealthy land owners who exploited the local people to work their mines. This was primarily driven by the British who sought secure trading routes from China as well as these minerals. In 1819 they gained Singapore and soon began trading lands with the Dutch to gain control of Malacca and other lands in the region.
During this time the local Malay sultans generally accepted British rule in order to curb Siam's (Thailand) expansion south. This transition of power to Britain was essentially finalized in 1824 when the Dutch signed a treaty with them defining each's territory in what is now Indonesia and Malaysia. British dominance continued as they became the protectorate of more and more lands, eventually creating the Federated Malay States.
In the late 1800s the British gained control over much of northern Borneo. One Brit in particular, James Brooke helped the local Sultans of Brunei and was given control over the Sarawak district, but he soon wanted more land and began taking lands from the Sultanate of Brunei. Despite British objections, the land soon came under British rule and later a part of Malaysia. Lands were also taken from the Spanish in northern Borneo during this time.
In the early 1900s the British gained lands on the Malay Peninsula from Siam and they were formalizing these land gains with the Dutch and locals as the modern day borders of Malaysia were slowly created.
By the early 1900s the region was also becoming more diverse as the Chinese came in to work the tin mines and the Indians arrived to work the rubber industry. However the Malays remained fairly happy since they held all police and military control as well as nearly every non-European seat in the local governing bodies.
When war broke out in 1939 in Europe the British became pre-occupied quite quickly at home so when the Japanese attacked Malaysia in the early 1940s they quickly overran the entire territory. The Japanese were harsh to the ethnic Chinese in the region and they quickly developed resistance movement as the ethnic Malays and Indians generally sided with the British, but had few options and often times worked with the Japanese.
After World War II the British began discussing independence with Malaysia, at first making Singapore and Borneo independent. However the final settlement included Borneo as Singapore gained independence. Before independence though, a growing communist movement, primarily among the ethnic Chinese arose and the British slowly crushed this movement. By 1957 this had been almost completely accomplished and the country gained independence in 1963 with the Malays, Chinese, and Indians all agreeing to the terms of the new country, which was led by Malay sultans, but with representation by all groups. Singapore and Brunei remained in this country for the time, but with great autonomy and they later each became independence.
By the late 1960s ethnic tensions had risen, but the people moved to political movements to solve these instead of violence. Oddly it was the ethnic Malays who had troubles obtaining jobs and soon laws were shifted to benefit them.
In the 1980s the country fell upon hard times economically. Since then there has been a slow recovery, which is best symbolized by the Petronas Twin Towers in Kuala Lumpur, which were built in 2012 as the tallest buildings in the world.
Today the country is most commonly criticized for having a fairly unrepresented political body as the sultans continue to hold a great amount of power and the same party has been in power since 1957.