Formulating the issue, an-Nawawi says in al-Majmu’: “Suppose a person owes a debt to another person and at the same time he qualifies for zakah. [When zakah is due for the lender to pay,] he tells [the borrower]: ‘Consider the debt for [my] zakah.’ Would it be valid?” An-Nawawi says there are two opinions on it. According to Ahmad and Abu Hanifah, who held the better opinion, it does not constitute zakah because it cannot be discharged unless actually paid, while Hasan al-Basri and ‘Ata maintain that the responsibility to pay zakah will be discharged even though there is no payment of zakah (at that point in time) by its payer.
Likewise, if an individual trustingly assigns some money to a person to keep and at the time of zakah he asks the assignee to keep the amount in lieu of his zakah, it will be valid.
The jurists, however, agree that if a person pays zakah to another who owes him money and then receives it back to redeem his loan to him, the obligation to pay zakah will not be discharged. It is also invalid for a person to accept zakah on the condition that he will pay it back to the lender (the zakah payer) for the amount he owes him. Nevertheless, if at the time of lending and acceptance of the loan both agree to do so, even though it was not mentioned in the deal, it will be valid as zakah.