Question: Very often circumstances call for honouring an open sinner (fāsiq) and one who disbelieves by misinterpretation (kāfir al-taʾwīl), and sitting with him, and perhaps he requests supplication (duʿā’). To leave honouring him, or to leave sitting with him, or to leave supplicating for him may cause blame to be attached to the one who leaves that, and his being described as lacking in dignity (muruʾah) and baseness of character. So what is the solution to that?
Answer: There is no objection to honouring an open sinner or one who disbelieves by misinterpretation, or to sitting with him.
However, it is proper that this be only to the extent that need calls for, or that dignity (muruʾah) requires. And as for supplication, if it is for the good things of this world, then there is also no objection to it, such as (supplicating for) provision, security, well-being and safety. Likewise, it is permissible to supplicate for the person mentioned for guidance.
In summary: everything that Allah, Exalted is He, gives in this world to the disbeliever and the open sinner, it is permissible to supplicate for him to have it. As for supplicating for them for forgiveness, reward, and that which contains good of the Hereafter, that is not permissible.
Yes, it is not permissible to sit with the open sinner at the time of his open sinning, nor with the disbeliever at the time of his plunging into talk of disbelief.
Thus, what we mentioned previously about the permissibility of sitting with the open sinner and the one who disbelieves by misinterpretation when there is a need—the intent is outward companionship and social interaction, according to what need, dignity, and noble character call for. He is not to open his heart to them; rather, it is required that his heart be averse to them and hateful toward them.
If it is said: The implication of your earlier words is that it is permissible to supplicate for the oppressor and the open sinner for long life, yet it has come (in narration): “Whoever supplicates for an oppressor that he remain (alive) has loved that Allah be disobeyed,” or as it is narrated.
We say: Long life is among the things that it is permissible for Allah to give to the open sinner, the disbeliever, the oppressor, and others besides them; indeed Allah has done that, and He, Exalted is He, still does it. He has informed us in His Book that He will use long lifespans as an argument against them, when He, Exalted is He, said: “Did We not give you life long enough so that whoever would remember therein could remember, and the warner had come to you? So taste the punishment …” [Fāṭir:37] At that point, then, there is no objection to supplicating with that which is in accordance with Allah’s established way (sunnah) in His servants.
As for the narration you mentioned, its meaning is: whoever supplicates for an oppressor for long life for the sake of his oppressing, has loved that Allah be disobeyed; and supplicating for the oppressor for this purpose is not permissible and not lawful.
Once you know this, there is no contradiction between what we have mentioned and that narration.
Source: Min Thimār al-ʿIlm wa al-Ḥikmah vol.2