Prayer (Kitab Al-Salat): Details of Commencing Prayer
Dawud :: Book 3 : Hadith 1023
Narrated Abdullah ibn Mas'ud:
AbuUbaydah reported, on the authority of his father Abdullah (ibn Mas'ud), the Apostle of Allah (peace_be_upon_him) as saying: When you offer the prayer, and you are in doubt about the number of rak'ahs whether offered three or four, and you have prayed four rak'ahs in all probability in your opinion, you should recite tashahhud and make two prostrations while you are sitting before giving the salutation. afterwards you should recite the tashahhud and give the salutation again.