Islamic law is based upon four main sources:
Muslims believe the Quran
to be the direct words of Allah, as revealed to and transmitted by the Prophet Muhammad. All sources of Islamic law must be in essential agreement with the Quran, the most fundamental source of Islamic knowledge. When the Quran itself does not speak directly or in detail about a certain subject, Muslims only then turn to alternative sources of Islamic law.
is the traditions or known practices of the Prophet Muhammad, many of which have been recorded in the volumes of Hadith
literature. The resources include many things that he said, did, or agreed to -- and he lived his life according to the Quran, putting the Quran into practice in his own life. During his lifetime, the Prophet's family and companions observed him and shared with others exactly what they had seen in his words and behaviors -- i.e. how he performed ablutions, how he prayed, and how he performed many other acts of worship. People also asked the Prophet directly for rulings on various matters, and he would pronounce his judgment. All of these details were passed on and recorded, to be referred to in future legal rulings. Many issues concerning personal conduct, community and family relations, political matters, etc. were addressed during the time of the Prophet, decided by him, and recorded. The Sunnah can thus clarify details of what is stated generally in the Quran.
In situations when Muslims have not been able to find a specific legal ruling in the Quran or Sunnah, the consensus of the community is sought (or at least the consensus of the legal scholars within the community). The Prophet Muhammad once said that his community (i.e. the Muslim community) would never agree on an error.
In cases when something needs a legal ruling, but has not been clearly addressed in the other sources, judges may use analogy, reasoning, and legal precedent to decide new case law. This is often the case when a general principle can be applied to new situations. (See the article Smoking in Islam
for an example of this process at work.)