After starting with some basics definition, discussing why sunnah is a source of legislation, summarizing the teaching methodology of our beloved Prophet (may the peace and blessings of Allah be upon him), looking into the spread of hadith during his time, and then during the time of the companions and their followers, we finally come to answering a critical question - how and when was hadith written down (preserved in writing)?
As with the previous parts, this post will not provide an exhaustive study, but rather highlights based on the Dr. Muhammad Ajaj Al Khatib's book - Usool al-Hadith.
If you don't have time to continue reading the post here's the short answer: Hadith was written down individually as early as the time of the Prophet (peace be upon him) and continued to be transmitted in writing (as well as verbally). However, the first formal order by a khalifah (caliph) to collect Hadith in writing was at the turn of the second century (after hijrah) during the time of Umar ibn Abdul- Aziz.
Part of the confusion regarding the writing of hadith is due to the presence of conflicting ahadeeth on this matter. There are authentic narrations which prohibit the writing of hadith and others which encourage it.
For example, there is an authentic hadith narrated by Abu Saeed al-Khudariy in Sahih Muslim in which the Prophet (peace be upon him) clearly prohibits the writing of hadith and orders the companions who have written any words from him other than Qura’n to erase them.
On the other hand there is hadith narrated by Abdullah ibn Amr ibn al-As in Sunnan Ad-Dirami in which the Prophet (peace be upon him) clearly orders him to write hadith. There is also another hadith narrated by Abu Hurairah in which one of the ansar complains to the Prophet (peace be upon him) about his lack of memorization, at which point the Prophet (peace be upon him) advises him to "aid his memorization with his right hand."
To reconcile the above ahadith (and others like them), scholars have provided the following explanations:
1. Prophet Muhammad (peace be upon him) prohibited the writing of Hadith during the early days of Islam to avoid confusion between Hadith and Qura’n.
2. Prophet Muhammad (peace be upon him) allowed the learned companions such as Abdullah ibn Omar to write hadith since they were not at risk of making a mistake in writing it or confusing it with Qura’n.
3. Prophet Muhammad (peace be upon him) allowed companions with weak memory to write hadith.
During the time of the companions (may Allah be pleased with them), there were times when they would prohibited the writing of hadith due to their fear of Muslims confusing it with Qura’n or getting preoccupied with it (and neglecting Qura’n), and there were other times where it was made permissible due to the absence of the above prohibitive circumstances. At the end of the day, all companions had the same intention: preserving hadith. The situation was similar during the time of the followers (tabi`een) - may Allah be pleased with them.
Around 100 years A.H., the fifth righteous Caliph Umar ibn Abdul-Aziz formally ordered the collection of hadith. Omar feared the loss and distortion of hadith due to the death of many of the companions, and to the new phenomenon of fabricated ahadith which began in that time due to political and sectarian disputes.
Shortly after that, many scholars began classifying ahadith based on their chain of narration or topic. As such, the turn of the second hijri century was not the beginning of the collection and preservation of hadith, but the beginning of its classification.
As for the earliest examples of written ahadith, the most famous is Abdullah ibn Amr ibn al-As's as-Sahifah as-Sadiqah (the Truthful Scroll) which included a thousand hadith (according to ibn al-Athir) which he wrote directly from the Prophet of Allah (peace be upon him). This document was cherished by Abdullah ibn Amr and passed on to his family after his death.
May Allah (swt) reward all the great scholars who have dedicated their lives to the collection and teaching of the hadith of Prophet Muhammad (peace be upon him), and give us the honor of being of those who studied, understood, and applied it.
P.S. I have tried my best to ensure this series of posts is as accurate as possible. Any mistakes are from myself. Please let me know if you find any - jazakum Allah khairan.