Ibn ʿUmar said, "While the Prophet ﷺ was on the pulpit, a man asked him how to offer the night prayers. He replied, 'Pray two rakʿat at a time and then two and then two and so on, and if you are afraid of the dawn (the approach of the time of the Fajr prayer) pray one rakʿa and that will be the witr for all the rakʿat which you have offered." Ibn ʿUmar said, "The last rakʿat of the night prayer should be odd, for the Prophet ﷺ ordered it to be so.
سَأَلَ رَجُلٌ النَّبِيَّ ﷺ وَهْوَ عَلَى الْمِنْبَرِ مَا تَرَى فِي صَلاَةِ اللَّيْلِ قَالَ مَثْنَى مَثْنَى فَإِذَا خَشِيَ الصُّبْحَ صَلَّى وَاحِدَةً فَأَوْتَرَتْ لَهُ مَا صَلَّى وَإِنَّهُ كَانَ يَقُولُ اجْعَلُوا آخِرَ صَلاَتِكُمْ وِتْرًا فَإِنَّ النَّبِيَّ ﷺ أَمَرَ بِهِ