There is no doubt that the Muslim is influenced by his friend, especially if he loves his friend dearly, because that love makes him turn a blind eye to his friend’s sins and errors, and it may lead him to admire him to such an extent that he begins to imitate him in everything, even the way he walks. This is something that is seen a great deal but no one can deny it.
You should understand that this friendship will turn to enmity of the Day of Resurrection, because this friendship was not based on adhering to the laws of Allah and obeying Him
Allah says (interpretation of the meaning): “Friends on that Day will be foes one to another except Al-Muttaqoon (the pious)” [az-Zukhruf 43:67].
Al-Qurtubi (may Allah have mercy on him) said: “Friends on that Day” i.e., the Day of Resurrection “will be foes one to another” i.e., they will be enemies to one another and will curse one another “except Al-Muttaqoon (the pious)” who will be friends in this world and in the Hereafter.
End quote from Tafseer al-Qurtubi, 16/95
Ibn Katheer (may Allah have mercy on him) said in Tafseer Ibn Katheer (7/237): That is, every friendship that was for the sake of anything other than Allah will, on the Day of Resurrection, turn into enmity, except for that which was for the sake of Allah, may He be glorified and exalted; it will last for ever. End quote.
What the Muslim must do is to keep away from bad companions and choose righteous friends who will guide him towards what is good and help him to obey his Lord, may He be exalted. As the saying goes: tell me who your friends are and I will tell you who you are.
The poet ‘Adiyy ibn Zayd said:
Do not ask about the man; look at his friend, for a man will follow in the footsteps of his friends.
It is sufficient deterrent from having bad friends for the Muslim to remember the warning against that, that is mentioned in the Prophet’s Sunnah:
It was narrated that Abu Moosa al-Ash‘ari (may Allah be pleased with him) said: The Messenger of Allah (blessings and peace of Allah be upon him) said:
“The likeness of a good companion and a bad companion is that of one who carries musk and one who works the bellows. With the carrier of musk, either he will give you some or you will buy some from him, or you will notice a good smell from him; as for the one who works the bellows, either he will burn your clothes or you will notice a bad smell from him.”
Narrated by al-Bukhaari, 1995; Muslim, 2628
Shaykh ‘Abd al-‘Azeez ibn Baaz (may Allah have mercy on him) said: Keeping company with good people is one of the best of deeds that bring one closer to Allah, and is one of the best means of attaining blessing. On the other hand, keeping company with bad people such as disbelievers and those who commit sin openly is not permissible, and is one of the things that lead to a bad end and cause one to adopt their attitudes and deeds.
What the believer must do is try hard to keep company with good people and avoid keeping company with bad people. It is not permissible to obey parents or others with regard to keeping company with bad people or forsaking good people, because the Prophet (blessings and peace of Allah be upon him) said: “Obedience is only with regard to that which is right and proper.” And he (blessings and peace of Allah be upon him) said: “There is no obedience to any created being if it involves disobedience to the Creator.”