Indonesia is constitutionally a secular state (but the government officially recognises only six formal religions), with Islam being the dominant religion in the country. Indonesia also has a larger Muslim population than any other country in the world, with approximately 202.9 million identifying themselves as Muslim (87.2% of Indonesia's total population in 2011).
Based on demographic statistics, 99% of Indonesian Muslims mainly follow the Shafi'i school of Sunni jurisprudence, although when asked, 56% does not adhere to any specific denomination. There are around one million Shias (0.5%), who are concentrated around Jakarta, and about 400,000 Ahmadi Muslims (0.2%). In general, Muslims in Indonesia can be categorised in terms of two orientations: "modernists" who closely adhere to orthodox theology while embracing modern learning, and "traditionalists," who tend to follow the interpretations of local religious leaders and religious teachers at Islamic boarding schools (pesantren).
There is evidence of Arab Muslim traders entering Indonesia as early as the 8th century. Indonesia's historical inhabitants were animists, Hindus and Buddhists. However, it was not until the end of the 13th century that the spread of Islam began.
The spread, although at first introduced through Arab Muslim traders, continued to saturate through the Indonesian people as local rulers and royalty began to adopt it, subsequently their subjects would mirror their conversion. The spread of Islam continued as Muslim traders married the local women, with some of the wealthier traders marrying into the families of the ruling elite.
In general, traders and the royalty of major kingdoms were the first to adopt the new religion. By the end of the thirteenth century, Islam had been established in Northern Sumatra; by the fourteenth in northeast Malaya, Brunei, the southwestern Philippines and among some courts of coastal East and Central Java; and the fifteenth in Malacca and other areas of the Malay Peninsula. Dominant kingdoms included Samudra Pasai in northern Sumatra, Demak Sultanate and Mataram in Central Java, and the sultanates of Ternate and Tidore in the Maluku Islands to the east.