In the second year of Hijrah, Muslims were commanded to fast in the month of Ramadhan every year.
Allah the Exalted Says in The Qur’an:
“O you who believe, fasting is prescribed for you as it was prescribed for those who were before you, in order that you may learn taqwa (piety)” (Surah Al-Baqarah, 2:183)
“The month of Ramadhan is that in which was revealed the Qur’an, wherein is guidance for mankind and the clear signs of guidance and distinction. Thus whosoever among you witness the month must fast...” (Surah Al-Baqarah, 2:184).
The Prophet Muhammad SAW explained this further in a number of his statements reported in the books of Hadith.
On the authority of Ibn ‘Umar that the Messenger of Allah SAW said, “Islam is built upon five pillars: testifying that there is no god except Allah and that Muhammad is the Messenger of Allah, performing Prayer, paying the zakah, making the pilgrimage to the Sacred House (Hajj), and fasting the month of Ramadhan.” [Al-Bukhari and Muslim]
The fasting in the month of Ramadhan is obligatory upon every person who is capable (mukallaf).