Sahih Muslim , Book 13, Hadith 148 (In-Book)

Abdullah b. 'Umar (Allah be pleased with them) reported that (the Arabs of) pre-Islamic days used to observe fast on the day of Ashura and the Messenger of Allah observed it and the Muslims too (observed it) before fasting in Ramadan became obligatory. But when it became obligatory, the Messenger of Allah said: 'Ashura is one of the days of Allah, so he who wished should observe fast and he who wished otherwise should abandon it.

حَدَّثَنَا أَبُو بَكْرِ بْنُ أَبِي شَيْبَةَ، حَدَّثَنَا عَبْدُ اللَّهِ بْنُ نُمَيْرٍ، ح وَحَدَّثَنَا ابْنُ نُمَيْرٍ، - وَاللَّفْظُ لَهُ - حَدَّثَنَا أَبِي، حَدَّثَنَا عُبَيْدُ اللَّهِ، عَنْ نَافِعٍ، أَخْبَرَنِي عَبْدُ اللَّهِ بْنُ عُمَرَ، رضى الله عنهما أَنَّ أَهْلَ، الْجَاهِلِيَّةِ كَانُوا يَصُومُونَ يَوْمَ عَاشُورَاءَ وَأَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم صَامَهُ وَالْمُسْلِمُونَ قَبْلَ أَنْ يُفْتَرَضَ رَمَضَانُ فَلَمَّا افْتُرِضَ رَمَضَانُ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏ "‏ إِنَّ عَاشُورَاءَ يَوْمٌ مِنْ أَيَّامِ اللَّهِ فَمَنْ شَاءَ صَامَهُ وَمَنْ شَاءَ تَرَكَهُ ‏" ‏ ‏.‏

sunnah.com