It is narrated from Sayyiduna Ubayy bin Ka'b (may Allah be pleased with him) that the Companions compiled the Qur'an into written copies (masahif) during the caliphate of Sayyiduna Abu Bakr (may Allah be pleased with him). Some men were writing while Sayyiduna Ubayy bin Ka'b (may Allah be pleased with him) was dictating to them. When they reached this verse of Surah Bara'ah: "Then they turn away. Allah has turned their hearts away, because they are a people who do not understand," they thought that this was the last verse of the Qur'an to be revealed. Thereupon Sayyiduna Ubayy bin Ka'b (may Allah be pleased with him) said to them: "Indeed, the Messenger of Allah (peace and blessings be upon him) taught me two more verses after it: 'There has certainly come to you a Messenger from among yourselves; grievous to him is what you suffer; he is concerned over you, and to the believers he is kind and merciful,' up to 'and He is the Lord of the Great Throne.'"
He said: "This is the last revelation to be sent down of the Qur'an."
He said: "So Allah Almighty concluded the matter with the very thing with which He had begun it, namely 'Allah, there is no god but He' (Allah, besides whom there is no god); and this is the statement of Allah, the Blessed and Exalted: 'And We did not send before you any messenger except that We revealed to him that there is no god but Me, so worship Me.'"