The Prophet ﷺ said, "Whoever catches two rakahs of the Asr prayer before the sun sets, or one rakah of the Fajr prayer before the sun rises, has caught the prayer."
أخبرنا محمد بن عبد الأعلى قال حدثنا معتمر قال سمعت معمرا عن ابن طاوس عن أبيه عن ابن عباس
عن النبي ﷺ قال من أدرك ركعتين من صلاة العصر قبل أن تغرب الشمس أو ركعة من صلاة الصبح قبل أن تطلع الشمس فقد أدرك
Reported by Muslim, Mosques, chapter, "Whoever catches a rakat of the prayer has caught that prayer," hadith no. 165/608, from the hadith of Mutamir, with this same wording. It is also in Al-Kubra, hadith no. 1501.