Most archaeologists estimate that the earliest settlers arrived in outrigger canoes from southern Borneo in successive waves throughout the period between 350 BCE and 550 CE, making Madagascar one of the last major landmasses on Earth to be settled by humans. By 600 CE groups of these early settlers had begun clearing the forests of the central highlands. Arabs first reached the island between the seventh and ninth centuries, and a wave of Bantu-speaking East African migrants arrived around 1000 CE and introduced zebu, a type of long-horned humped cattle, which were kept in large herds.
Madagascar was an important transoceanic trading hub connecting ports of the Indian Ocean in the early centuries following human settlement. The written history of Madagascar began with the Arabs, who established trading posts along the northwest coast by at least the 10th century and introduced Islam, the Arabic script (used to transcribe the Malagasy language in a form of writing known as sorabe), Arab astrology and other cultural elements.
In 1607, a group of Bugis settlers from Luwu Kingdom, southern Sulawesi, led by Arung Luempa landed in the site that today know as Tannanalo, Eastern Madagascar (OTL Mahanoro). The settlers were went abroad from their homeland in order to avoid the Islamization of Luwu by Datuk Patimang. The Bugis settlers then established the Kingdom of Sompe ("Sompe" means "sail" in Bugis and also a shortened form of "Passompe", the Bugis word for "the people who migrated from their homeland").
Ironically, the Malagasy Bugis later being Islamized in 1691 by Sheikh Abu Idris Al-Fiqr, an ulema from Hadhramaut (now part of the South Arabian Federation), commonly known by the locals as "Datok Lanjong" for his tall stature. The fifth descendant of Arung Luempa, Arung Mabinggi, converted to Islam in 1690 and adopted the Islamic name "Malik Abdurrahman". Under the rule of Arung Malik Abdurrahman and his son, Arung Abdul Ghaffar, the Sompe Kingdom extended its influence over another tribes and kingdoms in eastern coast of the islands.
The attempt to politically and economically dominating the island by the Sompe Kingdom led to a long-time rivalry between the coastal Bugis and the highlander Merina in 1709. The rivalry finally erupted into the Bugis-Merina War in 1731 after the Merina attempted to invade the settlements of Tanala people, the subject of Sompe Kingdom. The Bugis defeated the Merina in 1737 and Sompe emerged as the dominant kingdom in eastern Madagascar.
The Merina, Betsileo, and Tanala all being Islamized in late 18th century by the effort from the Bugis ulemas, such as Datok Lompi, Datok Keteng, and Datok Lembu. The newly-converted indigenous tribes quickly referred by the Sompe as the "Havoana" (the people from highland) while the Bugis-descended people that live in coastal areas simply identified themselves as the "Sompe". Other Malagasy tribes that not being converted to Islam yet referred as the "Batu", from Bugis word of "Battu", means "the indigenous people".
From about 1740 to 1848, Madagascar gained prominence among Arab, Malay, Indian, and European traders being a transit between the traffic of spice trades from India, Malacca, and Maluku Islands. The wealth generated by maritime trade spurred the rise of Sompe Kingdom as an important trade partner for the Europeans in the Indian Ocean.
main page: Protectorate of Madagascar
Under the rule of Arung Mohammad Karim Rashid, Sompe expanded its influence toward west between 1801 to 1809. Sompe expansion bitterly resisted by the Batu warriors from the western coast of Madagascar. To conquer the Batu, Arung Mohammad concluded the first treaty between the Sompe and the Danes with the Danish governor of Frederikkyst (OTL Antsiranana), Wilhelm Bremen Petersson, in northern Madagascar on March 21, 1803. The treaty guaranteed the Danes to have a special right for the spice trades that passed Madagascar in return for Danish military and financial assistance.
Following the death of Arung Mohammad Karim, the civil war broke out between the supporters of legal successor of Sompe throne, Arung Muda Hashim Badrullah and the supporters of pro-Danish Arung Muda Ilhamullah Malik Hasan in 1837. After 1845, the Sompe Kingdom divided between the Danish-supported northern court, known as the Rajang Kingdom, ruled by the descendants of Malik Hasan and the anti-Danish southern court, known as Lotanraja Kingdom, ruled by the descendants of Hashim Badrullah.
In 1860, prerogative powers of both royal courts effectively vanished after Lotanraja accepted the treaty of protection for 100 years offered by the Scandinavians following the failed invasion from Oman Sultanate. Between 1860 and 1960, Madagascar became a Scandinavian protectorate.
Under Scandinavian colonial rule, numerous policies were adopted by the colonial government to modernize the island. The upgrading the infrastructure of ports and roads and improvement of water irrigation became a high priority of Scandinavian colonial policy. Rubber plantations were established for the production of a variety of export crops. Traditional slavery was abolished in 1878. Education became mandatory between the ages of 6 to 13 and focused primarily on Danish language and practical skills. Most of Malagasy people remembered the period as "A Hundred-Year Enlightenment."
Compared with other colonial rules in the world, Scandinavian Madagascar relatively stable and peaceful without any significant military uprisings by the natives. Malagasy rulers and nobility felt reluctant to seek an independence from the Scandinavians and remained loyal during two World Wars (World War I and World War II) which guaranteed by their Pledges of Loyalty to the Scandinavian Crown that must signed and ratified by every Malagasy rulers since 1870 which required a renewal every ten years.
Despite the successes of Scandinavian colonial policy, a Malagasy national movement for self-government developed significantly, starting with the Malagasy Constitutional Congress in 1931. The Congress attended mostly by Malagasy young intellectuals, a new class emerged due to the colonial policy on education, and aimed for a responsible government in Madagascar which ran by Malagasy native peoples and an elevation of Madagascar from a colony to a constituent country within Scandinavian Union.
Andrian Mohammad Dawud Mataeng, the prominent and charismatic leader of Malagasy Constitutional Congress, sent the letter to the Scandinavian Commissioner-General for Madagascar, Karl Gustavson Braunstein, in 1933 which demanded for the representation of Madagascar in the Rigsdagen and the formation of Malagasy native legislature as the part of constitutional development of Madagascar. Braunstein, in his reply letter, stated Madagascar is still too immature to get its own self-government and would be impossible for being an integral part of the Union. However, Braunstein promised Mataeng to fulfill the second demand by advising the Rigsdagen to allow the formation of a Malagasy legislature. The first Legislative Council of Madagascar convened in 1934 and opened by Commissioner-General Braunstein.
The Malagasy division of Scandinavian Army, known as "De Frivilliges", under Lieutenant Andri Bakhri Pattalopong (1898-1969), fought for Scandinavia against the Wehrmacht in World War II. After the war, Scandinavian Crown acknowledged the Malagasy war services and awarded the Cross of Honour of the Order of the Dannebrog for Pattalopong and other 12 Malagasy officers that participated in the Battle of Christiania and the Lapland War.
At the end of World War II, the Dawlat Action Movement was emerged as the main supporter for Malagasy independence. Led by Hasan Ali Lompo, the Dawlat comprised by the Malagasy Social Democratic Party, the Malagasy Islamic Congress, the Batu Christian Patriotic Party; and the All-Malagasy Arab Council. Unlike the Malagasy Constitutional Congress, the Dawlat advocated for the total and complete independence of Madagascar and against the renewal of the Pledges of Loyalty to the Scandinavian Crown that they viewed had been exploiting the sovereignty of Malagasy nation.
The Malagasy Federal Government was formed in 1952 with Andrian Salih Pakis, the prime minister of the Kingdom of Rajang, as its first executive head. All Malagasy traditional polities ceased its domestic responsibility and formally transferred it to the Federal Government that responsible to the Commissioner-General. The MFG formation was opposed by either conservative right-wing and progressive left-wing. The conservatives, represented by the United Malagasy Congress, viewed the MFG had taken over the power of traditional rulers, while the progressives, represented by the Dawlat Movement, believed the MFG is fruitless and nothing to do in the advancement of future independence.
In 1956, the Dawlat Movement won the election of Legislative Council by gained 25 of 34 allocated seats at the council. Hasan Ali Lompo was appointed as the executive head of Federal Government on October 24, 1956. In 1957, the Constitution of United Kingdom of Madagascar was ratified by the monarchs from nineteen kingdoms of Madagascar and the Federal Government. Powers that formerly attributed to the Commissioner-General now was transferred to the newly-established Parliament of Madagascar. One year later, exactly on December 13, 1958, the independence of Madagascar was declared as the "Malagasy Federation"