This is part of the lengthy hadith of ‘Alī reported by Muslim (1), concerning the Prophet’s opening supplication, peace and blessings be upon him, and what he would say (2) while bowing and prostrating. Muslim gives two wordings: the first (3) states that the Prophet, peace and blessings be upon him, would say it between the tashahhud (testimony of faith) and the closing salām. This is the correct wording. The second (4) states that he would say it after the salām. Perhaps he would say it at both points. Allah knows best.
Imam Ahmad (5) reported that Zayd ibn Arqam said: The Messenger of Allah, peace and blessings be upon him, would say after every prayer:
“O Allah, our Lord and the Lord of all things, I bear witness that You alone are the Lord, without partner. O Allah, our Lord and the Lord of all things, I bear witness that Muhammad is Your servant and Messenger. O Allah, our Lord and the Lord of all things, I bear witness that all Your servants are brothers. O Allah, our Lord and the Lord of all things, make me and my family sincerely devoted to You at every moment of this life and the Hereafter. O Possessor of Majesty and Honor, hear and answer. Allah is the Greatest, the Greatest. Allah is the Light of the heavens and the earth. Allah (6) is the Greatest, the Greatest. Allah is sufficient for me, and He is the best Disposer of affairs. Allah is the Greatest, the Greatest.”
Abū Dāwūd also reported it.