It is narrated from Nafi' (may Allah have mercy on him) who states: I was with Ibn Umar (may Allah be pleased with them both) in Makkah and there were clouds covering the sky. Ibn Umar (may Allah be pleased with them both) feared that true dawn had appeared, so he performed one rak'ah of witr. Then the clouds cleared, and he saw that it was still night, so he made it even by performing another rak'ah.
Hadith Referenceمسند الإمام الشافعي / كتاب الصلاة / 392
Hadith Takhrijاسنادہ صحیح: اخرجه البيهقى فى معرفة السنن والآثار (1395) - ومالك في الموطا، كتاب الصلاة، باب صلوة النبي ﷺ في الوتر.