Narrated ‘Aisha (radiallaahu `anhaa):
The people used to fast on ‘Ashura (the tenth day of the month of Muharram) before the fasting of Ramadan was made obligatory. And on that day the Ka’ba used to be covered with a cover. When Allah made the fasting of the month of Ramadan compulsory, Allah’s Apostle (sallallaahu `alayhi wasallam) said, “Whoever wishes to fast (on the day of ‘Ashura’) may do so; and whoever wishes to leave it can do so.”
It is mustahab to fast on `Ashura and to fast on the 9th along with it as well.
‘Abdullah ibn ‘Abbas (may Allah be pleased with them both) said: “When the Messenger of Allah (peace and blessings of Allah be upon him) fasted on ‘Ashura’ and commanded the Muslims to fast as well, they said, ‘O Messenger of Allah, it is a day that is venerated by the Jews and Christians.’ The Messenger of Allah (peace and blessings of Allah be upon him) said, ‘If I live to see the next year, in sha Allah, we will fast on the ninth day too.’ But it so happened that the Messenger of Allah (peace and blessings of Allah be upon him) passed away before the next year came.” [Reported by Muslim, 1916]
Ash-Shafi’i and his companions, Ahmad, Ishaq and others said: “It is mustahabb to fast on both the ninth and tenth days, because the Prophet (peace and blessings of Allah be upon him) fasted on the tenth, and intended to fast on the ninth.”