Sayyiduna Abdullah bin Sarjis, who lived during the time of the Prophet Muhammad (peace be upon him), narrated this incident. The Prophet Muhammad (peace be upon him) was leading the Fajr prayer. During this time, a man came and performed two rak'ahs behind him, then joined the congregation for the (congregational) prayer with the attendees. When the Prophet Muhammad (peace be upon him) completed his prayer, he asked him: Which prayer have you considered as your prayer? The prayer that you performed alone, or the prayer that you performed with us?
Hadith Referenceصحیح ابن حبان / كتاب الصلاة / 2192
Hadith Gradingفضيلة الشيخ الإمام محمد ناصر الدين الألبانيصحيح - انظر ما قبله.فضيلة الشيخ العلّامة شُعيب الأرناؤوطإسناده صحيح، رجاله ثقات رجال الصحيح، وهو مكرر ما قبله.