السلام عليكم ورحمة الله وبركاته
The first thing is that we should make du’a to Allah سبحانه وتعالى to keep us steadfast. There are a number of du’as from the Qur’an and Sunnah which we can use. In every prayer, we make du’a for guidance in surah al-Fatihah, ‘“Guide us to the Straight Way.” [Al-Fatihah 1:6]
The Prophet صلى الله عليه وسلم would frequently supplicate, يَا مُقَلِّبَ الْقُلُوبِ ثَبِّتْ قَلْبِي عَلَى دِينِكَ (O Changer of the hearts, make my heart firm upon Your religion). [Jami` at-Tirmidhi 3522]
In another Hadith, the Prophet صلى الله عليه وسلم taught one of his Companions the following du’a:
اللَّهُمَّ إِنِّي أَسْأَلُكَ الثَّبَاتَ فِي الْأَمْرِ، وَالْعَزِيمَةَ عَلَى الرُّشْدِ، وَأَسْأَلُكَ مُوجِبَاتِ رَحْمَتِكَ، وَعَزَائِمَ مَغْفِرَتِكَ
(O Allah, verily I ask You for steadfastness in this matter (religion), and I ask You for the resolve to adhere to the path of guidance, and I ask You for the means of Your Mercy and forgiveness...). [At-Tabarani 7135]
Secondly, being mindful of Allah by observing His laws and commandments. At-Tirmidhi (2516) narrated that the Prophet صلى الله عليه وسلم said: “Be mindful of Allah; He will take care of you. Be mindful of Allah; you will find Him with you.”
Allah will take care of a person in terms of his physical wellbeing, wealth, family and, most importantly, his religious commitment. This means that Allah will keep him safe from deviation and misguidance, because the more a person follows guidance, the more Allah will increase him in guidance.
“While as for those who accept guidance, He increases their guidance, and bestows on them their piety” [Surah Muhammad 47:17].
May Allah increase us in guidance and keep us steadfast, Ameen.