The sources from which the Hanafi madhhab derives Islamic law are, in order of importance and preference: the Quran, and the hadiths containing the words, actions and customs of the Islamic prophetMuhammad (narrated in six hadith collections, of which Sahih Bukhari and Sahih Muslim are the most relied upon); if these sources were ambiguous on an issue, then the consensus of the Sahabah community (Ijma of the companions of Muhammad), then individual's opinion from the Sahabah, Qiyas (analogy), Istihsan (juristic preference), and finally local Urf (local custom of people).
Abu Hanifa is regarded by modern scholarship as the first to formally adopt and institute analogy (Qiyas) as a method to derive Islamic law when the Quran and hadiths are silent or ambiguous in their guidance.
The foundational texts of Hanafi madhhab, credited to Ab? ?an?fa and his students Abu Yusuf and Muhammad al-Shaybani, include Al-fiqh al-akbar (theological book on jurisprudence), Al-fiqh al-absat (general book on jurisprudence), Kitab al-athar (thousands of hadiths with commentary), Kitab al-kharaj and Kitab al-siyar (doctrine of war against unbelievers, distribution of spoils of war among Muslims, apostasy and taxation of dhimmi).
As the fourth Caliph, Ali had transferred the Islamic capital to Kufa, and many of the first generation of Muslims had settled there, the Hanafi school of law based many of its rulings on the earliest Islamic traditions as transmitted by Sahaba residing in Iraq. Thus, the Hanafi school came to be known as the Kufan or Iraqi school in earlier times. Ali and Abdullah, son of Masud formed much of the base of the school, as well as other personalities such as Muhammad al-Baqir, Ja'far al-Sadiq, and Zayd ibn Ali. Many jurists and historians had lived in Kufa including one of Abu Hanifa's main teachers, Hammad ibn Sulayman.
In the early history of Islam, Hanafi doctrine was not fully compiled. The fiqh was fully compiled and documented in the 11th century.
The Turkish rulers were some of the earliest adopters of the relatively more flexible Hanafi fiqh, and preferred it over the traditionalist Medina-based fiqhs which favored correlating all laws to Quran and Hadiths and disfavored Islamic law based on discretion of jurists. The Abbasids patronized the Hanafi school from the 10th century onwards. The Seljuk Turkish dynasties of 11th and 12th centuries, followed by Ottomans adopted Hanafi fiqh. The Turkic expansion spread Hanafi fiqh through Central Asia and into Indian subcontinent, with the establishment of Seljuk Empire, Timurid dynasty, Khanates, Delhi Sultanate, Bengal Sultanate and Mughal Empire. Throughout the reign of Emperor Aurangzeb the Hanafi based Fatawa-e-Alamgiri served as the legal, juridical, political, and financial code of most of South Asia.
Nurit Tsafrir, The History of an Islamic School of Law: The Early Spread of Hanafism (Harvard, Harvard Law School, 2004) (Harvard Series in Islamic Law, 3).
Behnam Sadeghi (2013), The Logic of Law Making in Islam: Women and Prayer in the Legal Tradition, Cambridge University Press, Chapter 6, "The Historical Development of Hanafi Reasoning", ISBN978-1107009097
Theory of Hanafi law: Kitab Al-Athar of Imam Abu Hanifah, Translator: Abdussamad, Editors: Mufti 'Abdur Rahman Ibn Yusuf, Shaykh Muhammad Akram (Oxford Centre of Islamic Studies), ISBN978-0954738013