All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger. We ask Allaah to exalt his mention as well as that of his family and all his companions.
The prayer was made compulsory on Al-Israa' (the night of Ascension) about five years before the migration, or six years according to another opinion. Al-Mardaawi, may Allaah have mercy on him, said that it happened approximately one year after Muhammad, the Prophet was made a Prophet. However, Ibn Hajar said: 'A group of scholars are of the view that there was no obligatory prayer, it was only the night prayer that was legislated without being specified as to how many. However, Al-Harbi is of the view that the obligatory prayer was two Rak’as in the morning and two Rak’as in the evening. Meanwhile, Ash-Shaafi’ee stated the view of some scholars, that the night prayer was made obligatory and then it was abrogated by the Saying of Allaah (which means): {So recite as much of the Quran as may be easy for you.}[Quran 73:20]. Thus the obligatory prayer was to perform the night prayers during some of the nights and not every night, and subsequently this was abrogated by enjoining the five daily obligatory prayers.'
Allaah Knows best.