Bear in mind that you should not establish friendship with all and sundry. However if a person possesses the following five qualities, there will be no harm in establishing friendship with the person:
The person must be intelligent. The reason for this is that one is unable to maintain a friendship with a person who is dim-witted and unwise. Another reason is that at times he might wish to help or benefit you in some way but because of his foolishness the opposite happens and he causes you harm.
2. Mild temperament.
The person’s manners, behaviour and temperament must be good. He must not befriend you for his personal gain. He must not lose control of himself when he becomes angry. He must not be fickle or inconsistent over trivial matters (trivial matters must nor cause him to lose his affection towards you or break his friendship with you).
3. Religious Minded.
He must be religious minded. If the person does not fulfil the rights of Almighty Allah, how can you even hope that he will be faithful to you? Another reason is that if you see him repeatedly committing a sin and because of your friendship you do not prevent him from the sin, you yourself will no longer have any abhorrence for that sin. The effect of evil company is that you will also begin committing the same sins that the friend commits.
4. Not desirous of the world.
The friend you choose must not have love and desire for the world. By being in the company of such a person you will also develop the love for the world. On the contrary, if you sit in the company of a person who has no desire for the world, whose clothing is coarse, whose food is simple, who always speaks of the fleeting nature of the world, then whatever desire you have for the temporary world will also disappear.
He must not be in the habit of speaking lies. This is because one cannot rely on a person who speaks lies. It is possible that you might consider something that he says to be true while in actual fact it is a lie and you are thereby misled by him.
Note: One should take these 5 factors into consideration even before one can befriend anyone.
(Source: Bahishti Zewar / Heavenly Ornaments)