Fasting on Ashura, the tenth of Muharram, is prescribed and recommended.
Hafiz Ibn Abd al-Barr, may Allah have mercy on him (463 AH), says:
[لا يختلف العلماء أن يوم عاشوراء ليس بفرض صيامه ولا فرض الا صوم رمضان]
There is no disagreement among the scholars that fasting on Ashura is not obligatory; only the fasts of Ramadan are obligatory.
Our master Abu Hurairah, may Allah be pleased with him, narrates that the Messenger of Allah ﷺ said:
[أفضل الصيام، بعد رمضان، شهر الله المحرم]
After the month of Ramadan, the best fast is that of Muharram.
Our master Muawiyah ibn Abi Sufyan, may Allah be pleased with both of them, stated from the pulpit that he heard the Messenger of Allah ﷺ say:
[هذا يوم عاشوراء ولم يكتب الله عليكم صيامه، وأنا صائم، فمن شاء، فليصم ومن شاء، فليفطر]
This is the day of Ashura; Allah has not made fasting on this day obligatory. Whoever wishes may fast, and whoever wishes may not fast, but I will fast.
Our master Abu Qatada al-Ansari, may Allah be pleased with him, narrates that the Messenger of Allah ﷺ was asked about fasting on Ashura, and he said:
[يكفر السنة الماضية]
It is an expiation for the sins of one year.
Our master Abdullah ibn Abbas, may Allah be pleased with both of them, narrates that the Messenger of Allah ﷺ said:
[إن عشت إن شاء الله إلى قابل صمت التاسع؛ مخافة أن يفوتني يوم عاشوراء]
If life permits, then God willing, I will fast on the ninth of Muharram next year as well, out of fear that the Day of Ashura might be missed.
Hafiz Bayhaqi, may Allah have mercy on him (458 AH), says:
[أما حدیث التاسع فیحتمل عندی وجوہا، أحدھا: أن یرید صومہ احتیاطا، فربما نقص الھلال ویکون الغیم، فتکمل العدة ثلاثین، فیکون التاسع فی العدد ھو العاشر من الھلال، فأحب أن لا یفوتہ]
There can be several meanings of the hadith about fasting on the ninth of Muharram, one of which is that the Prophet Muhammad ﷺ intended to fast on the ninth of Muharram as a precaution. This is because if the crescent of Dhu al-Hijjah is sighted on the 29th and it is cloudy that day, then the thirty days of Dhu al-Hijjah are completed. Thus, when fasting on the ninth of Muharram, what is considered the ninth is actually the tenth of Muharram. So the Prophet ﷺ wanted to ensure that the fast of Ashura would not be missed in this way.
Our master Abdullah bin Abbas, may Allah be pleased with them both, narrates that the Messenger of Allah ﷺ said:
[إذا كان العام المقبل إن شاء الله صمنا اليوم التاسع قال: فلم يأت العام المقبل، حتى توفي رسول الله صلى الله عليه وسلم]
Next year, God willing, we will fast on the ninth of Muharram as well. But the next year, the Messenger of Allah ﷺ passed away.
The wording of one narration is:
[لئن بقيت إلى قابل لأصومن التاسع]
If I live until next year, I will also fast on the ninth of Muharram.
Sayyiduna Abdullah bin Abbas (may Allah be pleased with them) says:
[إذا رأيت هلال المحرم فاعدد، وأصبح يوم التاسع صائما، قلت: هكذا كان رسول الله صلى الله عليه وسلم يصومه؟ قال: نعم]
When you see the moon of Muharram, start counting the days and fast on the ninth of Muharram. I (Hakam bin Arraj) asked: Did the Prophet ﷺ fast on that day? He said: Yes.
Sayyiduna Abdullah bin Abbas (may Allah be pleased with them) says:
[صوموا التاسع والعاشر وخالفوا اليهود]
Fast on the ninth and tenth of Muharram and oppose the Jews.