Messenger of Allah ﷺ said, "If anyone of you can get one rakʿa of the ʿAsr prayer before sunset, he should complete his prayer. If any of you can get one rakʿa of the Fajr prayer before sunrise, he should complete his prayer." (Using translation from Bukhārī 556)
أَنَّ النَّبِيَّ ﷺ قَالَ إِذَا أَدْرَكَ أَحَدُكُمْ أَوَّلَ سَجْدَةٍ مِنْ صَلَاةِ الْعَصْرِ قَبْلَ أَنْ تَغْرُبَ الشَّمْسُ فَلْيُتِمَّ صَلَاتَهُ وَإِذَا أَدْرَكَ أَوَّلَ سَجْدَةٍ مِنْ صَلَاةِ الصُّبْحِ قَبْلَ أَنْ تَطْلُعَ الشَّمْسُ فَلْيُتِمَّ صَلَاتَهُ