Sahih al-Bukhari, Hadith 6265

Narrated Ibn Mas`ud: Allah's Messenger taught me the Tashah-hud as he taught me a Sura from the Qur'an, while my hand was between his hands. (Tashah-hud was) all the best compliments and the prayers and the good things are for Allah. Peace and Allah's Mercy and Blessings be on you, O Prophet! Peace be on us and on the pious slaves of Allah, I testify that none has the right to be worshipped but Allah, and I also testify that Muhammad is Allah's slave and His Apostle. (We used to recite this in the prayer) during the lifetime of the Prophet, but when he had died, we used to say, "Peace be on the Prophet."

حَدَّثَنَا أَبُو نُعَيْمٍ، حَدَّثَنَا سَيْفٌ، قَالَ سَمِعْتُ مُجَاهِدًا، يَقُولُ حَدَّثَنِي عَبْدُ اللَّهِ بْنُ سَخْبَرَةَ أَبُو مَعْمَرٍ، قَالَ سَمِعْتُ ابْنَ مَسْعُودٍ، يَقُولُ عَلَّمَنِي رَسُولُ اللَّهِ صلى الله عليه وسلم وَكَفِّي بَيْنَ كَفَّيْهِ التَّشَهُّدَ، كَمَا يُعَلِّمُنِي السُّورَةَ مِنَ الْقُرْآنِ التَّحِيَّاتُ لِلَّهِ وَالصَّلَوَاتُ وَالطَّيِّبَاتُ، السَّلاَمُ عَلَيْكَ أَيُّهَا النَّبِيُّ وَرَحْمَةُ اللَّهِ وَبَرَكَاتُهُ، السَّلاَمُ عَلَيْنَا وَعَلَى عِبَادِ اللَّهِ الصَّالِحِينَ، أَشْهَدُ أَنْ لاَ إِلَهَ إِلاَّ اللَّهُ وَأَشْهَدُ أَنَّ مُحَمَّدًا عَبْدُهُ وَرَسُولُهُ‏.‏ وَهْوَ بَيْنَ ظَهْرَانَيْنَا، فَلَمَّا قُبِضَ قُلْنَا السَّلاَمُ‏.‏ يَعْنِي عَلَى النَّبِيِّ صلى الله عليه وسلم‏.‏

sunnah.com