The Messenger of Allah ﷺ said, "Whoever catches one rakah of the prayer has caught the prayer."
أن رسول الله ﷺ قال: من أدرك ركعة من الصلاة فقد أدرك الصلاة.
Malik narrated it in "The Times of Prayer" (15) from Ibn Shihab, from Abu Salama bin Abdul-Rahman, from Abu Hurairah, and he mentioned the hadith. From Malik, Bukhari narrated it in "The Prayer Times" (580), and Muslim in "The Mosques" (607). In a version reported by Muslim, "Whoever catches a rakat of the prayer with the imam has caught the prayer."