Praise be to Allah.
This is a matter concerning which the salaf differed. Some of them allowed that, and some of them did not allow it. Some of the scholars differentiated between a person whose wealth is mostly haraam, and said that it is either obligatory or mustahabb to avoid him, and one whose wealth is mostly halaal, in which case it is permissible to deal with him and eat from his food.
For more details on this matter, please see Jaami’ al-‘Uloom wa’l-Hukam by Ibn Rajab, commentary on hadeeth no. 6.
Shaykh Ibn ‘Uthaymeen (may Allaah have mercy on him) was asked: Is it permissible to accept gifts form a man who deals in riba?
The basic principle is that what is haraam because of the way in which it is acquired is haraam for the one who acquires it, but not for one who takes it from him in a permissible manner. The Prophet (peace and blessings of Allaah be upon him) accepted gifts from the Jews, as when a Jewish woman gave him a sheep in Khaybar. He also dealt with them; when he died his shield was in pledge to a Jew. He did this even though they dealt in riba, as Allaah tells us about them (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). And We have prepared for the disbelievers among them a painful torment”
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, in which case we should refrain from doing so because of 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.
For example, if I were to be given a gift of some wine by a Jew or a Christian – who believes that wine is permissible – it is not permissible for me to accept it, because it is haraam in and of itself.
Similarly, if a person were to steal some money and give some to another person, it is not permissible to accept it, because this money is haraam in and of itself (by virtue of it having been stolen).
Liqaa’aat al-Baab il-Maftooh, no. 2, 1/76.