The Prophet (peace and blessings of Allaah be upon him) used to deal with the Jews, buying and selling, and he accepted gifts from them, even though they dealt in riba.
Allaah says (interpretation of the meaning):
“For the wrongdoing of the Jews, We made unlawful for them certain good foods which had been lawful for them — and for their hindering many from Allaah’s Way;
161. And their taking of Ribaa (usury) though they were forbidden from taking it and their devouring of men’s substance wrongfully (bribery)”
Despite that, the Prophet (peace and blessings of Allaah be upon him) accepted their gifts. He accepted the gift of the Jewish woman who brought the (roast) sheep in Khaybar, he interacted with them and when he died his shield was in pledge to a Jew.
The basic principle here is: That which is forbidden because of the way in which it is earned is haraam only for the one who earns it, and not for the one who takes it from him in a permissible manner. Based on this, it is permissible to accept a gift from one who deals in riba, and it is also permissible to buy from him and sell to him, unless there is some interest to be served by shunning him, i.e., if there is some interest to be served by not dealing with him and not accepting his gifts. In that case we should do that in order to achieve that interest. With regard to that which is haraam in and of itself, it is haraam for the one who takes it and for others. So for example, if a Jew or a Christian who thinks that wine is permissible were to offer me some wine as a gift, it is not permissible for me to accept it because it is haraam in and of itself. If a person were to steal someone’s money and give it to me, it is haraam for me to take this stolen money because it is haraam in and of itself.
This principle dispels a great deal of confusion. That which is haraam because of the way in which it was acquired is haraam only to the one who acquires it, not to anyone who takes it in a permissible manner, unless shunning him and not taking anything from him and not accepting his gift or dealing with him will serve an interest by deterring him from doing such things; in that case he should be shunned in order to achieve that purpose.