(5) Establishing the Prayer and the Sunnah Regarding Them
كتاب إقامة الصلاة والسنة فيها
(87) Chapter: Concerning one who enters the mosque while the Imam is delivering the sermon
(87) باب مَا جَاءَ فِيمَنْ دَخَلَ الْمَسْجِدَ وَالإِمَامُ يَخْطُبُ
Sunan Ibn Majah 1112 
It was narrated that Jabir bin ‘Abdullah said:
“Sulaik Ghatafani entered the mosque when the Prophet (ﷺ) was delivering the sermon. He said: ‘Have you prayed?’ He said: ‘No.’ He said: ‘Then perform two Rak’ah.’”
حَدَّثَنَا هِشَامُ بْنُ عَمَّارٍ، حَدَّثَنَا سُفْيَانُ بْنُ عُيَيْنَةَ، عَنْ عَمْرِو بْنِ دِينَارٍ، سَمِعَ جَابِرًا، وَأَبُو الزُّبَيْرِ، سَمِعَ جَابِرَ بْنَ عَبْدِ اللَّهِ، قَالَ دَخَلَ سُلَيْكٌ الْغَطَفَانِيُّ الْمَسْجِدَ وَالنَّبِيُّ ـ صلى الله عليه وسلم ـ يَخْطُبُ ‏.‏ فَقَالَ ‏"‏ أَصَلَّيْتَ؟ ‏"‏ ‏.‏ قَالَ: لاَ ‏.‏ قَالَ ‏"‏ فَصَلِّ رَكْعَتَيْنِ ‏"‏ ‏.‏
وَأَمَّا عَمْرٌو فَلَمْ يَذْكُرْ سُلَيْكًا ‏.‏
Grade :  Sahih (Darussalam)
Reference : Sunan Ibn Majah 1112
In-book reference : Book 5, Hadith 310
English translation : Vol. 1, Book 5, Hadith 1112