The Prophet ﷺ said, "Allah accepts the repentance of His servant as long as the death rattle has not reached his throat."
عن النبي ﷺ قال: إن الله يقبل توبة العبد ما لم يغرغر.
It was narrated by Tirmidhi (3537) and Ahmad (6160), and Ibn Hibban (628) and Hakim (4/257) graded it sahih, all of them by way of Abdul-Rahman bin Thabit bin Thawban, from his father, from Makhul, from Jubayr bin Nufayr, from Ibn Umar, who related it. Tirmidhi said, "This is a hasan gharib hadith." Hakim said, "Its chain is sahih." I say, its chain is hasan because of Abdul-Rahman bin Thabit, for he is one whose hadith is hasan.As for what was narrated from Ibn Abbas, who said, the Prophet ﷺ said, "Jibreel kept stuffing mud into Pharaoh's mouth for fear that he would say, 'There is no god but Allah.'" And in another version, "so that Allah would have mercy on him, or for fear that Allah would have mercy on him." The correct view is that this is a report attributed only to the companion, not the Prophet. It was narrated by Tirmidhi (3108), Ahmad (2144), and Ibn Hibban (6215), all of them from the hadith of Shubah, who said, "Adi bin Thabit and Ata bin Saaib told me, from Saeed bin Jubayr, from Ibn Abbas," and one of the two raised it to the Prophet ﷺ.I say, Hakim (2/340) narrated it from Shubah, from Adi bin Thabit, with the same wording, attributing it to the Prophet, and said, "This is a sahih hadith meeting the criteria of the two Shaykhs, though they did not include it. However, most of Shubah's companions narrated it as stopped at Ibn Abbas." End of quote. And that latter view is the correct one.As for Pharaoh's utterance, "I believe that there is no god except Him in whom the children of Israel believe, and I am among the Muslims" [Yunus 10:90], that occurred at the moment of drowning, when he saw the agonies of death. Allah accepts the servant's repentance as long as he has not yet reached the death rattle, as mentioned before.