‘Imran b. Husain said that the Prophet led them in prayer and forgot something, so he made two prostrations, then uttered the shahada, then gave the salutation.
Tirmidhi transmitted it and said this is a hasan gharib tradition.
‘Abdallah ibn Buhaina said that the Prophet led them in the noon prayer, and when he stood up at the end of the first two rak'as and did not sit, the people stood up along with him. When he finished the prayer and the people expected him to give the salutation, he said “God is most great" while sitting and made two prostrations before giving the salutation. Then he gave it.
Al-Mughira b. Shu'ba reported God’s Messenger as saying, “When an imam stands up at the end of two rak'as, if he remembers before standing straight up he should sit down, but if he stands straight up he must not sit down, but perform the two prostrations of forgetfulness.”
Narrated Ibn Sirin reported Abu Huraira as saying:
God’s Messenger led us in one of the two evening ('ashiy)1 prayers. (Ibn Sirin said that Abu Huraira named it, but he had forgotten which, it was.) He led us in two rak'as and when he had given the salutation he got up, and going towards a piece of wood which was placed crosswise in the mosque, he leaned on it looking as if he were angry. He placed his right hand on his left, and intertwining his fingers, he placed his right cheek on the back of his left hand. Those who were first to come out of the doors of the mosque said, “The prayer has been shortened." Abu Bakr and ‘Umar were among the people, but they were too afraid to speak to him; but among them was a man with such long arms that he was called “The possessor of arms" (Dhulyadain) who asked, “Have you forgotten, Messenger of God, or has the prayer been shortened?” He replied, “I have neither forgotten, nor has it been shortened." He then asked whether things were as the possessor of arms had said, and when he was told that that was so he went forward and prayed what he had omitted. He then gave the salutation, then said “God is most great" and made his usual prostration or one a little longer, then raised his head and said “God is most great", then said “God is most great" and made his usual prostration or one a little longer, then raised his head and said “God is most great". He2 was often asked whether he then gave the salutation and he would say: I have been informed that ‘Imran b. Husain said he then gave the salutation.
1. ‘Ashiy generally means evening, but it also means the time between the declining of the sun after the meridian and sunset or morning, so the two prayers here mentioned are the noon (zuhr) prayer and the afternoon prayer.
2. i.e. Ibn Sirin
(Bukhari and Muslim, the wording being Bukhari’s.) In another version given by both of them, instead of saying “I have neither forgotten nor has it been shortened” God’s Messenger said, “None of that has happened," to which he replied, “Some of it has, Messenger of God."