When the Prophet ﷺ arrived in Medina, he found the people fasting on a particular day, namely Ashura. They said, "This is a great day. It is the day on which Allah saved Musa and drowned the people of Pharaoh, so Musa fasted it in gratitude to Allah."He said, "I have more right to Musa than they do." So he fasted it and commanded that it be fasted.
أن النبي ﷺ لما قدم المدينة وجدهم يصومون يوما يعني عاشوراء فقالوا: هذا يوم عظيم، وهو يوم نجى الله فيه موسى، وأغرق آل فرعون، فصام موسى شكرا الله، فقال: أنا أولى بموسى منهم فصامه وأمر بصيامه.
Bukhari narrated it in the chapters on the prophets (3397), and Muslim in the chapter on fasting (1130:127), both by way of Saeed bin Jubayr, from Ibn Abbas, who related it. This is the wording of Bukhari. In the wording of Muslim, it reads, "This is the day on which Allah gave Musa and Banu Israil victory over Pharaoh, so we fast it in honor of that." The Prophet ﷺ said, "We have more right to Musa than you do," and he ordered that it be fasted.