"Mother of the Believers, what was the supplication the Messenger of Allah ﷺ made most often when he was with you?"She replied, "His most frequent supplication was, 'Turner of hearts, keep my heart firm upon Your religion.'"She said, "I asked him, 'Messenger of Allah, why do you so often pray, Turner of hearts, keep my heart firm upon Your religion?'"He answered, "Umm Salama, there is no human being whose heart is not between two of the fingers of Allah. Whomever He wills, He keeps upright, and whomever He wills, He causes to deviate."Then Muaz recited, "Our Lord, do not cause our hearts to deviate after You have guided us" [Aal Imran 3:8].
حدثنا أبو موسى الأنصاري حدثنا معاذ بن معاذ عن أبي كعب صاحب الحرير حدثني شهر بن حوشب قال
يا أم المؤمنين ما كان أكثر دعاء رسول الله ﷺ إذا كان عندك قالت كان أكثر دعائه يا مقلب القلوب ثبت قلبي على دينك قالت فقلت يا رسول الله ما أكثر دعاءك يا مقلب القلوب ثبت قلبي على دينك قال يا أم سلمة إنه ليس آدمي إلا وقلبه بين أصبعين من أصابع الله فمن شاء أقام ومن شاء أزاغ فتلا معاذ {ربنا لا تزغ قلوبنا بعد إذ هديتنا}
Its isnad is hasan. Ahmad reported it, 6/315, from Muaz bin Muaz with the same wording.On this subject there are also narrations from Ayesha, Nawwas, and Anas [previously mentioned, 2140], Jabir [Hakim, 22/288, 289, and Abu Yaala, hadith 2318], Abdullah bin Amr [previously mentioned, 2140], and Naeem bin Hammar [Tabarani, and Abu Naeem in Marifat Sahabah, 5/2670, hadith 6397].