The last part of the Quran to be revealed was "There has certainly come to you a Messenger from among yourselves. Grievous to him is your suffering. He is deeply concerned for you, and toward the believers he is kind and merciful" [Tawbah 9:128].
آخر ما نزل من القرآن: {لقد جاءكم رسول من أنفسكم عزيز عليه ما عنتم حريص عليكم بالمؤمنين رءوف رحيم} ١٢٨ [سورة التوبة: ١٢٨].
Hakim (2/338) narrated it from Abu Abbas Muhammad bin Yaqub, who said, Bakkar bin Qutayba the judge told us, Abu Amir Abdullah bin Amr Aqdi told us, Shuba told us, from Yunus bin Ubayd and Ali bin Zayd, from Yusuf bin Mihran, from Ibn Abbas, from Ubayy bin Kaab bin Malik, and he related it.Hakim said, "The hadith of Shuba from Yunus bin Ubayd is sahih according to the standard of the two Shaykhs." As for Ali bin Zayd, who is Ibn Jadan, most scholars consider him daif, and perhaps for this reason Hakim graded the narration of Shuba from Yunus bin Ubayd as sahih, but did not grade the narration of Ali bin Zayd as sahih. Allah knows best.Wahidi narrated it in Asbab Nuzul (p. 13) through another route, from Shuba, from Ali bin Zayd, from Yusuf bin Mahak, from Ubayy bin Kaab, who said, "The Quran had a fresh covenant with Allah, "There has certainly come to you a messenger from among yourselves" [Tawbah 9:128], and the first day the Quran was revealed was a Monday."And through the route of Shuba, from him, from Yusuf bin Mihran, from Ibn Abbas, from Ubayy bin Kaab, Abdullah bin Ahmad narrated it in the additions to his father's work (21113), as he also narrated it through another route in his father's Musnad (21226), saying, Rawh bin Abdul-Mumin told us, Umar bin Shaqiq told us, Abu Jafar Razi told us, Rabi bin Anas told us, from Abu Aliyah, from Ubayy bin Kaab, "They gathered the Quran into written copies during the caliphate of Abu Bakr, and men would write while Ubayy bin Kaab dictated to them. When they reached this verse from Surah Baraah, "Then if they turn away, say, Allah has turned their hearts away because they are a people who do not understand" [Tawbah 9:127], they thought this was the last thing revealed of the Quran. Ubayy bin Kaab said to them, 'The Messenger of Allah ﷺ had me recite two verses after it, "There has certainly come to you a messenger from among yourselves. Grievous to him is what you suffer, he is full of concern for you, and to the believers he is kind and merciful" up to "and He is the Lord of the mighty throne" [128–129] [Tawbah 9:128–129].'" Then he said, "This is the last thing revealed of the Quran." He said, "So it closed with what it had opened with, 'Allah, there is no god but Him,' and this is the statement of Allah , "And We did not send any messenger before you except that We revealed to him that there is no god but Me, so worship Me" [Anbiya 21:25]."Abu Jafar Razi is Isa bin Abdullah bin Mahan, whom the Hafiz described as "truthful but weak in memory, especially regarding what he transmits from Mughira." He is acceptable in corroborating narrations.If this is sound, it should be understood as meaning that each of them spoke according to the knowledge that had reached him about the last portion revealed of the Quran, or that Ubayy bin Kaab meant by "the verse" the entirety of Surah Baraah, as is mentioned in the hadith of Bara bin Azib. Allah Most High knows best.