The Messenger of Allah ﷺ arrived in Medina and found the Jews fasting on the day of Ashura. The Messenger of Allah ﷺ asked them, "What is this day on which you are fasting?"They replied, "This is a great day. On it Allah saved Musa and his people and drowned Pharaoh and his people, so Musa fasted it in gratitude, and we fast it as well."The Messenger of Allah ﷺ said, "We have a greater claim to Musa than you do." So the Messenger of Allah ﷺ fasted on that day and ordered that it be observed as a fast.
أن رسول الله ﷺ قدم المدينة، فوجد اليهود صياما، يوم عاشوراء. فقال لهم رسول الله ﷺ: ما هذا اليوم الذي تصومونه؟ فقالوا: هذا يوم عظيم. أنجى الله فيه موسى وقومه، وغرق فرعون وقومه، فصامه موسى شكرا، فنحن نصومه. فقال رسول الله ﷺ: فنحن أحق وأولى بموسى منكم فصامه رسول الله ﷺ وأمر بصيامه.
Bukhari narrated it in the Book of Fasting (2004), and Muslim in the Book of Fasting (1130: 128), via Ayub, from Abdullah bin Saeed bin Jubayr, from his father, from Ibn Abbas, and he mentioned it. The wording is Muslim's.