Shehu Usman bn Fodio (1754–1817), a Fulani cleric of the Toronkawa clan, was tutor to the heir-apparent of Sarkin Gobir Bawa, but broke with the Hausa court over what he held to be syncretic Islamic practice and the unjust taxation of Muslims. After repeated harassment by Sarkin Gobir Yunfa, the Shehu performed the hijra from Degel to Gudu in February 1804 and proclaimed jihad. The community elected him Sarkin Musulmi (Commander of the Faithful) and granted him the flag of war.
The campaign of 1804–1808 conquered every Hausa city-state. Yunfa was killed at the Battle of Alkalawa in 1808; Sarkin Kano Alwali, Sarkin Katsina Magajin Halidu, Sarkin Zazzau and others were displaced. The Shehu's brother Abdullahi dan Fodio took the western flank (Gwandu Emirate), his son Muhammad Bello the eastern (Sokoto). At its height the Caliphate covered roughly 400,000 km² and 10 million inhabitants — modern north-western and north-central Nigeria, plus large parts of present-day Niger, Cameroon and Benin — governed through some thirty emirates each headed by a Fulani Emir holding a flag (tuta) granted personally by the Shehu or his successors as evidence of legitimate authority.
The Caliphate was a scholar's state. Shehu Usman, Abdullahi dan Fodio, Muhammad Bello, and Nana Asma'u (the Shehu's daughter, a poet, jurist, and educator who organised the Yan-Taru system of itinerant women teachers) collectively wrote over 300 surviving works in Arabic, Fulfulde and Hausa on theology, jurisprudence, government, women's education and history. Muhammad Bello's Infaq al-Maysur (1812) and Abdullahi's Diya al-Hukkam are constitutional documents of the Caliphate. Sokoto became one of the great centres of Maliki scholarship in 19th-century Africa.
Maliki law was codified, Sharia courts were established, slave-raiding of pagan peoples (Middle Belt populations: Gwari, Kakanda, Bauchi pagans) was systematised on an enormous scale to supply both the household and the export markets via Bida and Adamawa; the great slave market of Sokoto exceeded that of every Hausa city in the previous century.
The Caliphate was conquered by Frederick Lugard's West African Frontier Force in a fifteen-month campaign in 1902–1903. Kano fell on 3 February 1903; Sokoto fell on 15 March 1903 after the Battle of Sokoto. Sultan Muhammadu Attahiru I led a hijra eastward with several thousand followers but was killed at the Battle of Burmi in Gombe on 27 July 1903. Lugard installed Muhammadu Attahiru II as Sultan and reorganised the Caliphate as the indirect-rule system of the Protectorate of Northern Nigeria — preserving the emirates, the Native Authorities, and the Sharia courts in modified form. The 14th Sultan of Sokoto, His Eminence Sa'ad Abubakar III (installed November 2006), is the current spiritual head of Nigerian Muslims and the direct successor to Shehu Usman dan Fodio.