Allah clarifies in the Qur'an that Muhammad, may Allah bless him and grant him peace, is His Messenger and that "those who are with him are fierce to the disbelievers, merciful to one another". (Surat al-Fath: 29)
As this verse makes explicit, the people to whom believers show compassion are again believers, that is, those who have faith in Allah and who fear Him. One and above all else, they fulfil this as a command of Allah. This aside, seeing a believer's love for Allah, his elevated morality and his striving to earn Allah's approval and the exemplary morality he displays inspires a natural love, mercy and compassion in other believers' hearts. As is expressed in this verse, "Your friend is only Allah and His Messenger and those who believe: those who establish prayer and pay the welfare tax, and bow" (Surat al-Ma'ida: 55), believers know that they are the guardians of one another and act with the sincerity and fondness this acknowledgement brings. These attributes are expressed in another verse as follows:
The men and women of the believers are friends of one another. They command what is right and forbid what is wrong, and establish prayer and pay the welfare tax, and obey Allah and His Messenger. They are the people on whom Allah will have mercy. Allah is Almighty, All-Wise. (Surat at-Tawba: 71)
The Prophet, may Allah bless him and grant him peace, also told believers, "You will not be true believers until you are merciful with one another." (Bukhari and Muslim)
Thus, having this concept of friendship, believers aspire to eliminate all factors likely to cause trouble for one another and to create a peaceable and comfortable environment. They are aware that their brothers are weak servants of Allah like themselves. They acknowledge that they are apt to make mistakes, to commit errors of memory or to be forgetful. Therefore, they are never seized by feelings of anger or mercilessness and compassionately encourage one another to do good.
Nevertheless, Allah orders believers to be "fierce" to the disbelievers. That is because disbelievers struggle with the religion of Allah and even try to prevent people from living by it. This being the case, showing mercy to such people means turning a blind eye to the harm they are likely to do to religion. This is an utterly unacceptable situation with which believers would severely struggle until the end of their lives. Accordingly, they feel compassion towards sincere believers who fear Allah and who strive to earn Allah's approbation.