As the second source of authority in Islam, hadith complements the Qur'an and provides the most extensive source for Islamic law. The ultimate understanding of the Qur'an depends upon the context of Muhammad's life and the ways in which he demonstrated and applied its message. There is evidence that Muhammad's sayings and practices were invoked by his companions to answer questions about Islam. Unlike the Qur'an, however, in the early periods hadith was circulated orally, and no attempts were made to establish or codify it into law until the beginnings of the second century of Islam.
Due to the late beginnings of the efforts to collect and compile reports about Muhammad's traditions, Muslim scholars recognize that the authenticity of these reports cannot be taken for granted. Many spurious reports were often deliberately put into circulation to support claims of various political and sectarian groups. Other additions resulted from the natural tendency to confuse common practices that predated Islam with new Islamic laws and norms. The fading of memory, the dispersion of the companions of the prophet over vast territories, and the passing away of the last of these companions also contributed to the problem of authenticating Muhammad's traditions.
To establish the authority of hadith on firmer ground, Muslim scholars developed several disciplines dedicated to examining and verifying the relative authenticity of various reports attributed to the Prophet.
The contents of sayings, as well as the reliability of those who transmitted them, were carefully scrutinized, and the hadiths were classified into groups granted varying degrees of authenticity, ranging from the sound and reliable to the fabricated and rejected. This systematic effort culminated in the 9th century, some 250 years after the death of Muhammad, in the compilation of several collections of sound (sahih) hadith. Of six such highly reliable compilations, two in particular are considered by Muslims to be the most important sources of Islamic authority after the Qur'an. These are Sahih Muslim and Sahih Bukhari (the sound books of Muslim and Bukhari).
Historically, the compilation of hadith went hand in hand with the elaboration of Islamic law and the parallel development of Islamic legal theory. Initially, neither the law nor its procedures were systematically elaborated, although there can be little doubt that both the Qur'an and hadith were regularly invoked and used to derive laws that governed the lives of Muslims. By the beginning of the 9th century, the use of these two sources was systematized and a complex legal theory was introduced. In its developed form, this theory maintains that there are four sources from which Islamic law is derived. These are, in order of priority, the Qur'an, the hadith, the consensus of the community (ijma), and legal analogy (qiyas). Functional only when there is no explicit ruling in the Qur'an or hadith, consensus confers legitimacy retrospectively on historical practices of the Muslim community. In legal analogy, the causes for existing Islamic rulings are applied by analogy to similar cases for which there are no explicit statements in either the Qur'an or hadith. Using these methods, a vast and diverse body of Islamic law was laid out covering various aspects of personal and public life.
In addition to the laws pertaining to the five pillars, Islamic law covers areas such as dietary laws, purity laws, marriage and inheritance laws, commercial transaction laws, laws pertaining to relationships with non-Muslims, and criminal law. Jews and Christians living under Muslim rule are subject to the public laws of Islam, but they have traditionally been permitted to run their internal affairs on the basis of their own religious laws.