Praise be to Allah.
Qiyaam al-layl means spending the night, even if it is only for a short time, in prayer, reading Qur’an, remembering Allah (dhikr), and other acts of worship. It is not stipulated that it should take most of the night.
With regard to tahajjud, it is (voluntary) prayers at night. Some scholars stipulate that it is prayers at night that are offered after having slept.
However the view of most of the fuqaha’ is that it refers to any prayers offered at night.
See the answer to question no. 143240.
What is prescribed with regard to prayers at night is that the prayers should be offered two rak‘ahs by two, then the worshipper should end his prayers with one rak‘ah, so as to make the prayers odd-numbered.
It was narrated from Ibn ‘Umar that a man asked the Messenger of Allah (blessings and peace of Allah be upon him) about the prayers offered at night. The Messenger of Allah (blessings and peace of Allah be upon him) said: “The night prayers are two by two, then if one of you fears that dawn may come, he should pray one rak‘ah, which will make what he has prayed odd-numbered.”
Narrated by al-Bukhaari (946) and Muslim (749).
From that it is clear that the Sunnah with regard to tahajjud and Witr includes several things:
1. The worshipper should offer his prayers two (rak‘ahs) by two, so he should separate each two rak‘ahs of his prayer with the tasleem.
2. He should start with tahajjud first, and pray as much as Allah wills that he should pray.
3. Witr should be the last of his prayers at night. The Prophet (blessings and peace of Allah be upon him) said: “Make the last of your prayers at night Witr (lit. odd-numbered).” Narrated by al-Bukhaari (953) and Muslim (751).
4. The worshipper should not delay any of his tahajjud or Witr until the break of dawn; rather he should try to make sure that he has done all of that before the adhaan of Fajr.
An-Nawawi (may Allah have mercy on him) said:
The words of the Prophet (blessings and peace of Allah be upon him),” then if one of you fears that dawn may come, he should pray one rak‘ah, which will make what he has prayed odd-numbered” – and according to another hadith, he said, “Pray Witr before dawn” – indicates that the Sunnah is to make Witr the last of the prayers offered at night, and that the time for it ends with the break of dawn. This is the well-known view in our madhhab, and it is the view of the majority of scholars. It was also said that the time lasts after dawn has broken, until the obligatory prayer is offered.
End quote from Sharh Saheeh Muslim (6/30-32).
The Muslim may offer whatever prayers he wishes at night, from after ‘Isha’ prayer until dawn, depending on whatever he is able to to, whether at the beginning of the night, or in the middle of the night, or at the end thereof, with any number of rak‘ahs.
The best time for offering the prayers at night is the end of the night, for it is the time when Allah descends to the first heaven, and the time when the gates of heaven are opened. It was narrated that Jaabir (may Allah be pleased with him) said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “Whoever fears that he will not get up at the end of the night, let him pray Witr at the beginning. Whoever is sure that he will get up at the end of the night, let him pray Witr at the end, for prayer at the end of the night is witnessed, and that is better.” Narrated by Muslim (755).
If he prays at the beginning of the night, then prays Witr, then he decides to pray at the end of the night whatever he wishes, two rak‘ahs by two, he should not repeat Witr, for there should not be two Witrs in one night.
And Allah knows best.