Answer: If we begin with the second part of the question—there is no doubt that praying Qiyām al-Layl is virtuous throughout the entire year. However, the way it is prayed may differ somewhat in Ramaḍān.
The Virtue of Qiyām al-Layl Throughout the Year
Allāh عزّ وجلّ says in the Qur’ān:
تَتَجَافَىٰ جُنُوبُهُمْ عَنِ ٱلْمَضَاجِعِ
They forsake their beds (i.e., they rise in the night to pray). (Surah As-Sajdah: 16)
And Allāh عزّ وجلّ says:
كَانُوا۟ قَلِيلًا مِّنَ ٱلَّيْلِ مَا يَهْجَعُونَ
They used to sleep but little of the night. (Surah Adh-Dhāriyāt: 17)
And He عزّ وجلّ says:
وَٱلَّذِينَ يَبِيتُونَ لِرَبِّهِمْ سُجَّدًا وَقِيَـٰمًا
"And those who spend the night in prostration and standing before their Lord." (Surah Al-Furqān: 64)
The Messenger of Allāh ﷺ said in the ḥadīth of ‘Abdullāh ibn Salām رضي الله عنه:
يَا أَيُّهَا النَّاسُ، أَفْشُوا السَّلَامَ، وَأَطْعِمُوا الطَّعَامَ، وَصِلُوا الْأَرْحَامَ، وَصَلُّوا بِاللَّيْلِ وَالنَّاسُ نِيَامٌ، تَدْخُلُوا الْجَنَّةَ بِسَلَامٍ
"O people! Spread (the greeting of) Salam, feed others, uphold the ties of kinship, and pray during the night when people are sleeping, and you will enter Paradise with Salam.” (Sunan Ibn Majah 3251)
And in the ḥadīth of Abū Hurayrah رضي الله عنه, the Prophet ﷺ said:
أَفْضَلُ الصَّلَاةِ بَعْدَ الصَّلَاةِ الْمَكْتُوبَةِ الصَّلَاةُ فِي جَوْفِ اللَّيْلِ
"The best Salat after the prescribed Salat is Salat at night." (Muslim)
How Qiyām al-Layl in Ramaḍān Differs
One of the distinguishing features of Qiyām al-Layl in Ramaḍān is Tarāwīḥ. In reality, Tarāwīḥ is Qiyām al-Layl. There is no fundamental difference between them, except that Tarāwīḥ is prayed in congregation in the masjid, while outside of Ramaḍān, Qiyām is generally prayed individually.
There are examples in the Sunnah where someone joined another in night prayer, such as Ibn ‘Abbās رضي الله عنه praying with the Prophet ﷺ. However, organized group prayers for Qiyām outside of Ramaḍān were not a regular practice of the Ṣaḥābah.
The Prophet ﷺ used to pray Qiyām al-Layl between ‘Ishā’ and Fajr. Our mother ‘Ā’ishah رضي الله عنها narrated:
مَا كَانَ يَزِيدُ فِي رَمَضَانَ وَلَا فِي غَيْرِهِ عَلَى إِحْدَى عَشْرَةَ رَكْعَةً
"He did not pray more than eleven rak‘āt in Ramaḍān or outside of it." (Bukhārī & Muslim)
The scholars differed in how to count these eleven, but broadly speaking, it consists of eight rak‘āt of Qiyām and three rak‘āt of Witr.
Another distinction of Qiyām in Ramaḍān is that in the last ten nights, one may try to pray the entire night. Outside of these nights, it is not from the Sunnah to regularly stay up all night in prayer. The Prophet ﷺ criticized those who intended to do so consistently.
The Number of Rak‘āt for Tarāwīḥ
This brings us to the question of whether Tarāwīḥ should be 8 rak‘āt or 20 rak‘āt.
The Prophet ﷺ did not exceed eleven rak‘āt in his night prayer. However, the scholars of the Salaf did not consider this number as a restriction on praying more.
Ibn ‘Abd al-Barr رحمه الله said:
وَقَدْ أَجْمَعَ الْعُلَمَاءُ عَلَىٰ أَنَّهُ لَا حَدَّ وَلَا شَيْءَ مُقَدَّرًا فِي صَلَاةِ اللَّيْلِ
"The scholars have consensus that there is no fixed limit for the number of rak‘āt in night prayer."
Whoever wishes to stand for long periods with fewer rak‘āt may do so, and whoever wishes to increase their rukū‘ and sujūd with more rak‘āt may do so.
Similarly, Al-Qāḍī ‘Iyāḍ رحمه الله mentioned that there is no disagreement among scholars that there is no fixed limit to the number of rak‘āt in Qiyām.
At-Tirmidhī رحمه الله also noted in his Sunan that scholars differed regarding the number of rak‘āt, listing various opinions, yet he did not mention 8 rak‘āt as a singular fixed opinion.
Thus, the Prophet ﷺ prayed 8 rak‘āt of Qiyām, and if one wishes to follow this, then they have chosen well. However, if someone prays more rak‘āt with shorter recitation, there is no harm in that either.
This also applies to a masjid where the Imām prays 8 rak‘āt, but one wishes to continue praying extra rak‘āt afterward—this is permissible and within the flexibility of the Sunnah.
Conclusion
- The Prophet ﷺ prayed 8 rak‘āt of Qiyām (plus Witr).
- The scholars agree that there is no fixed number for Qiyām.
- Tarāwīḥ is simply Qiyām in congregation, not a different type of prayer.
- The flexibility in number allows for both 8 and 20 rak‘āt to be valid approaches.
Ultimately, there is ease and flexibility in the matter, and Allāh عزّ وجلّ knows best.
— Answered by Ustadh Muhammad Tim Humble