Short answer
Yes. The Quran says fasting was prescribed for those before us, and before Islam the Quraysh of Makkah and the Jews of Madinah fasted on the day of Ashura. But the fast of the month of Ramadan was made obligatory on Muslims in the second year after the Hijra.
The fast of Ramadan became fard in the second year after the Hijra. Before that, the Prophet ﷺ fasted Ashura and told the Muslims to fast it; once Ramadan was prescribed, Ashura became voluntary.
The four schools agree on this.
Explanation
Allah says: O you who believe, fasting has been decreed for you as it was decreed for those before you, so that you may become righteous. Fasting is one of the oldest acts of worship, kept in different forms by earlier prophets and their followers. The Quran mentions, for example, Maryam's vow to abstain from speaking for a day.
Ashura before Islam. Aishah said the Quraysh used to fast the day of Ashura in the time before Islam, and the Prophet ﷺ fasted it too. When he came to Madinah he found the Jews fasting it because Allah saved Musa on that day. He said: I have more right to Musa than you, and he fasted it and told the Muslims to fast it.
How Ramadan was prescribed. The fast of Ramadan was made obligatory in the second year after the Hijra. At first there was a choice: someone able to fast could instead feed a poor person for each day. Salamah ibn al-Akwa said this lasted until the following verse was revealed and replaced it, making the fast itself obligatory on every healthy resident. After that, Ashura became a voluntary fast.
Is the month itself older than Islam? Ramadan is an old Arabic month name, and the month existed in the Arab calendar before Islam. Fasting the whole month as worship began with the revelation, and Ramadan is the month in which the Quran was first sent down. See why Muslims fast and Ashura.
The evidence
Quran, Surah Al-Baqara 2:183
يَٰٓأَيُّهَا ٱلَّذِينَ ءَامَنُوا۟ كُتِبَ عَلَيْكُمُ ٱلصِّيَامُ كَمَا كُتِبَ عَلَى ٱلَّذِينَ مِن قَبْلِكُمْ لَعَلَّكُمْ تَتَّقُونَ ﴿١٨٣﴾
O you who have believed, decreed upon you is fasting as it was decreed upon those before you that you may become righteous -
Fasting was prescribed for earlier nations too.
Quran, Surah Al-Baqara 2:185
شَهْرُ رَمَضَانَ ٱلَّذِىٓ أُنزِلَ فِيهِ ٱلْقُرْءَانُ هُدًۭى لِّلنَّاسِ وَبَيِّنَٰتٍۢ مِّنَ ٱلْهُدَىٰ وَٱلْفُرْقَانِ ۚ فَمَن شَهِدَ مِنكُمُ ٱلشَّهْرَ فَلْيَصُمْهُ ۖ وَمَن كَانَ مَرِيضًا أَوْ عَلَىٰ سَفَرٍۢ فَعِدَّةٌۭ مِّنْ أَيَّامٍ أُخَرَ ۗ يُرِيدُ ٱللَّهُ بِكُمُ ٱلْيُسْرَ وَلَا يُرِيدُ بِكُمُ ٱلْعُسْرَ وَلِتُكْمِلُوا۟ ٱلْعِدَّةَ وَلِتُكَبِّرُوا۟ ٱللَّهَ عَلَىٰ مَا هَدَىٰكُمْ وَلَعَلَّكُمْ تَشْكُرُونَ ﴿١٨٥﴾
The month of Ramadhan [is that] in which was revealed the Qur'an, a guidance for the people and clear proofs of guidance and criterion. So whoever sights [the new moon of] the month, let him fast it; and whoever is ill or on a journey - then an equal number of other days. Allah intends for you ease and does not intend for you hardship and [wants] for you to complete the period and to glorify Allah for that [to] which He has guided you; and perhaps you will be grateful.
Ramadan was chosen for fasting because the Quran was revealed in it.
Sahih al-Bukhari 2002
Sahih... كان يوم عاشوراء تصومه قريش في الجاهلية ...
"The day of Ashura was fasted by the Quraysh in the time before Islam."
Fasting was known in Arabia before Islam.
Sahih al-Bukhari 2004
Sahih... فأنا أحق بموسى منكم فصامه وأمر بصيامه ...
"I have more right to Musa than you. So he fasted it and ordered it to be fasted."
The Jews of Madinah fasted Ashura, and the Prophet ﷺ affirmed the fast.
Sahih al-Bukhari 4507
Sahih... كان من أراد أن يفطر ويفتدي حتى نزلت الآية التي بعدها فنسختها ...
"Whoever wished could break the fast and pay a ransom, until the verse after it was revealed and abrogated it."
Ramadan was prescribed in stages, ending with the full obligation.
Where the ruling is recorded
- Radd al-Muhtar (Ibn Abidin), Kitab al-Sawm, opening section. Fasting Ramadan was made obligatory in Sha'ban of the second year after the Hijra.
Checked by our team. For a more accurate answer to your own situation, consult a scholar. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.