(a) Sayyiduna Yazid bin Amir (may Allah be pleased with him) said: When I came, the Prophet (peace and blessings be upon him) was praying. I sat down and did not join him (peace and blessings be upon him) in the prayer. When he (peace and blessings be upon him) finished the prayer, he saw me sitting. He (peace and blessings be upon him) said: "Yazid! Are you not a Muslim?" I replied: Certainly, O Messenger of Allah! I am a Muslim. He (peace and blessings be upon him) said: "Why did you not join the people in their prayer?" I said: I had prayed at home, and I thought that you would already have prayed. He (peace and blessings be upon him) said: "When you come to the mosque and find the people praying, pray with them, even if you have already prayed. Let that (earlier prayer) be voluntary for you, and this one obligatory."
(b) This hadith agrees with what has passed regarding repeating the prayer when one finds the congregation, but it differs from it as to which of the two is the obligatory one; what has passed is more numerous and better known, so it takes precedence. And Allah knows best.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3647