‘umar ibn al-khattaab reported that at the time of the prophet (peace and blessings of allaah be upon him), there was a man called ‘abd-allaah whose nickname was himaar (donkey), who used to make the messenger of allaah (peace and blessings of allaah be upon him) laugh. the prophet (peace and blessings of allaah be upon him) had him whipped for drinking – he was brought to him one day and the prophet (peace and blessings of allaah be upon him) gave orders that he should be whipped. one of the men present said, “o allaah, curse him! how often has he been brought [to be punished because of drinking]!” the prophet (peace and blessings of allaah be upon him) said,
“do not curse him, for by allaah, all i know of him is that he loves allaah and his messenger.” (reported by al-bukhaari, fath, 6780).
abu hurayrah said: “a drunkard was brought to the prophet (peace and blessings of allaah be upon him) and he ordered that he should be beaten, so some of us hit him with our hands, others with shoes and garments. when he went away, a man said, ‘may allaah put him to shame!’ the messenger of allaah (peace and blessings of allaah be upon him) said,
‘do not be a help to the shaytaan against your brother.’” (reported by al-bukhaari, al-fath, 6781).
abu hurayrah also said:
“a man who had been drinking was brought to the prophet (peace and blessings of allaah be upon him) and he said, ‘beat him.’ some of us hit him with our hands, others with shoes and clothes. when he went away, some of the people said, ‘may allaah put you to shame!’ the messenger of allaah (peace and blessings of allaah be upon him) said, ‘do not speak like this. do not help the shaytaan against him.’” (al-bukhaari, fath, 6777)
according to another report:
“then the messenger of allaah (peace and blessings of allaah be upon him) said to his companions, ‘rebuke him.’ so they turned to him and said, ‘you did not think of allaah, you did not fear allaah, you did not feel ashamed before the messenger of allaah (peace and blessings of allaah be upon him).’ then they let him go, and the prophet (peace and blessings of allaah be upon him) said, ‘say, “o allaah, forgive him, o allaah, have mercy on him”’ and some of them added similar sentiments.” (abu dawood, kitaab al-hudood, baab al-hadd fi’l-khamr, no. 4478, 4/620. classed as saheeh by al-albaani in saheeh abi dawood, no. 3759).
according to another report:
“when he went away, some of the people said, ‘may allaah put you to shame!’ the messenger of allaah (peace and blessings of allaah be upon him) said, ‘do not speak like this, do not help the shaytaan against him. say “may allaah have mercy on you.”’” (reported by ahmad, 2/300. ahmad shaakir said, its isnaad is saheeh. al-musnad, ed. by ahmad shaakir, no. 7973).
what we learn from all of these reports is that if the muslim falls into sin, he is still basically a muslim and still basically loves allaah and his messenger, and this should not be denied. it is not permitted to pray against him in a manner that helps the shaytaan against him; rather we should pray for him and ask allaah to guide him, forgive him and have mercy on him.