Nearly all people in Somalia are Sunni Muslims. For more than 1400 years, Islam made a great part of Somali society. Practicing Islam reinforces distinctions that further set Somalis apart from their immediate neighbors, many of whom are either Christians or adherents of indigenous faiths.
For generations, Islam in Somalia followed the Ash’ariyah theology, Shafi’i jurisprudence, and Sufism, until recent decades when Salafism has made inroads. Influence of Islamic religious leaders has varied by region, being greater in the north than among some groups in the settled regions of the south. Among nomads, the exigencies of pastoral life gave greater weight to the warrior's role, and religious leaders were expected to remain aloof from political matters.
The role of religious functionaries began to shrink in the 1950s and 1960s as some of their legal and educational powers and responsibilities were transferred to secular authorities. The position of religious leaders changed substantially after the 1969 revolution and the introduction of scientific socialism. Siad Barre insisted that his version of socialism was compatible with Qur'anic principles, and he condemned atheism. Religious leaders, however, were warned not to meddle in politics.
The new government instituted legal changes that some religious figures saw as contrary to Islamic precepts. The regime reacted sharply to criticism, executing some of the protesters. Subsequently, religious leaders seemed to accommodate themselves to the government.
Islam was introduced to the northern Somali coast early on from the Arabian peninsula, shortly after the hijra. Zeila's two-mihrab Masjid al-Qiblatayn although not dated, is said to have been built back in 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 littoral Benadir region to the south. Adal's history from this founding period forth would be characterized by a succession of battles with neighbouring Abyssinia.