Allaah (The Most High) said:
وَرَبَطْنَا عَلَىٰ قُلُوبِهِمْ إِذْ قَامُوا فَقَالُوا رَبُّنَا رَبُّ السَّمَاوَاتِ وَالْأَرْضِ لَن نَّدْعُوَ مِن دُونِهِ إِلَٰهًا ۖ لَّقَدْ قُلْنَا إِذًا شَطَطًا
And We made their hearts firm and strong when they stood up and said: “Our Lord is the Lord of the heavens and the earth, never shall we call upon anyilah (god) other than Him; if we did, we should indeed have uttered an enormity in disbelief. [18:14]
Those (young men) used to live in the midst of their people who were disbelievers and they used to serve their kingdom. Then they found the reality of Eemaan and Tawfeeq (i.e. in this case they were guided to the right path and enabled to act upon that guidance). They tasted the sweetness of Eemaan and their hearts were delighted, so (Allaah informed us that) they stood in the midst of their people and said:
[رَبُّنَا رَبُّ السَّمَاوَاتِ وَالْأَرْضِ -Our Lord is the Lord of the heavens and the earth]
The firmness and strength in their hearts necessitated a determination upon patience and steadfastness. Their hearts were strengthened and aided with the light of Eemaan to bear the separation from the land of their people and abandon the lowly life they were in. So they departed with their religion (of Tawheed) to the cave.
Firmness of the heart is the strength tied to the heart – it makes a person remember his Lord and follow what is pleasing to his Lord. The opposite of it is a weak resolve, which makes a person forgetful of the remembrance of his Lord; (makes him) follow his desires and thus his deeds are lost.
[Madaarij As-Saalikeen’ 3/67-68. paraphrased and abridged]