Most residents of Somalia are Muslims, the majority belonging to the Sunni branch of Islam and the Shafi'i school of Islamic jurisprudence, although some are adherents of the Shia Muslim denomination.Sufism, the mystical dimension of Islam, is also well-established, with many local jama'a (zawiya) or congregations of the various tariiqa or Sufi orders.
Article 2 of the Provisional Constitution of Somalia defines Islam as the state religion of the Federal Republic of Somalia, and Islamic sharia as the basic source for national legislation. It also stipulates that no law that is inconsistent with the basic tenets of Shari'a can be enacted. Article 11 guarantees equal rights and freedom from persecution for all citizens before the law regardless of religion. Additionally, Article 17 protects freedom of religion.
Islam entered the region very early on, shortly after the hijra. Zeila's two-mihrab Masjid al-Qiblatayn dates to the 7th century, and is the oldest mosque in the city. In the late 9th century, Al-Yaqubi wrote that Muslims were living along the northern Somali seaboard. He also mentioned that the Adal kingdom had its capital in the city, suggesting that the Adal Sultanate with Zeila as its headquarters dates back to at least the 9th or 10th century. According to I.M. Lewis, the polity was governed by local dynasties, who also ruled over the similarly-established Sultanate of Mogadishu in the Benadir region to the south.
In addition, the Somali community has produced numerous important Islamic figures over the centuries, many of whom have significantly shaped the course of Muslim learning and practice in the Horn of Africa, the Arabian Peninsula, and well beyond. Among these Islamic scholars is the 14th century Somali theologian and jurist Uthman bin Ali Zayla'i of Zeila, who wrote the single most authoritative text on the Hanafi school of Islam, consisting of four volumes known as the Tabayin al-Haqa'iq li Sharh Kanz al-Daqa'iq.
Christianity is a minority religion in Somalia, with no more than 1,000 practitioners (about 0.01% of the population). According to estimates of the Diocese of Mogadishu (the territory of which coincides with the country) there were only about 100 Catholic practitioners in Somalia in 2004.
In 1913, during the early part of the colonial era, there were virtually no Christians in the Somali territories, with only about 100-200 followers coming from the schools and orphanages of the few Catholic missions in the British Somaliland protectorate. There were also no known Catholic missions in Italian Somaliland during the same period. In the 1970s, during the reign of Somalia's then Marxist government, church-run schools were closed and missionaries sent home. There has been no archbishop in the country since 1989, and the cathedral in Mogadishu was severely damaged during the civil war.
According to the Pew Research Center, less than 0.1% of Somalia's population in 2010 were adherents of traditional or folk religions. These mainly consisted of some non-Somali ethnic minority groups in the southern parts of the country, who practice animism. In the case of the Bantu, these religious traditions were inherited from their ancestors in Southeast Africa, and include the practice of possession dances and the use of magic and curses.