Anas bin Malik relates that Allah’s Messenger ﷺ said: “There are three qualities; whosoever have them may taste sweetness of faith: first, one who loves Allah and His Messenger above all else; secondly, one who loves someone simply for the sake of Allah; and thirdly, one who abhors return to disbelief after Allah has rescued him from it, as he abhors being thrown into the fire (of hell).”
(Bukhari and Muslim)
Man has an instinct of loving. He wants to submit to and love a Supreme Being, but he does not know. He also does not know the right order of importance of whom he wants to submit to. In this hadith, the Blessed Prophet has put it in the right order: one who loves Allah and His Messenger more than all others and loves someone else simply for the sake of Allah can taste the sweetness of faith. His heart lights up with faith and he becomes steadfast.
A man loves his parents, wife and children. If his parents ask him to do something un-Islamic then his love for Allah emerges. The Blessed Prophet was the best husband to his wives. But, immediately after listening to the call of Prayer, he used to rush to the mosque as if he had nothing to do with them.
A steadfast Muslim should not adopt the company of those as run contrary to Islamic teachings. He should befriend only such persons as do not stand in his way, rather prove helpful in discharging of his duties.