The Torah forbids wine which was used for ritual worship of avoda zara. That wine is known as yayin nesech, and one may not drink, or even benefit from that wine. The laws of yayin nesech are discussed by the Shulhan Arukh in Yoreh De’ah 123. The Talmud (Avoda Zara 29b) derives this prohibition from a verse: “Who did eat the fat of their offerings, and drank the wine of their drink-offering” (Devarim 32:38). This verse juxtaposes the fat of gentile sacrifices to their wine: Just as deriving benefit from their offering is prohibited, so too, deriving benefit from their wine is prohibited.
The gemara (Shabbat 17b, Avoda Zara 36b) relates that on a certain day the Rabbis enacted eighteen new prohibitions, including stam yenam. This law prohibits all wine from the non-Jews, not just wine which was used for pagan worship. Similar to yayin nesech, the Talmud teaches that one may not drink, or benefit from this wine.
Rashi and Rashbam explain that while during the times of the Talmud, when pouring wine was part of the daily pagan service, the Rabbis completely forbid all wine from non-Jews. However, nowadays, when wine is no longer a prominent component of pagan rituals, and yayin nesech is rather uncommon, one may benefit from stam yenam, although it still cannot be consumed.
The Taz (Yoreh De’ah 123:1) questions this view. He notes that the general halachic principle is that once the Rabbis make a decree, only another bet din, of greater stature, can change or revoke the decree. Therefore, he disagrees with Rashi and Rashbam and maintains that the halacha is in accordance with those who rule that even nowadays one may not benefit from stam yenam.
Maran, in the Shulhan Arukh (123:1) rules that even nowadays one may not derive any benefit from stam yenam. The Rema is lenient and adopts the view of Rashi and the Rashbam.
Often, before the non-Jewish holidays, non-Jews give gifts to their friends and work associates. What if a person received a bottle of wine (stam yenam) from a non-Jew? May one give that wine to another gentile, which might be viewed as a form of benefit? According to Maran, this would be prohibited, and one must dispose of the wine. Although the Rema himself writes “tov lehahmir” – it is best to be stringent, he still rules in accordance with Rashi and Rashbam and it should be permitted, according to them, to dispose of the wine.
However, the Maharam Shik, a student of the Hatam Sofer, was asked whether one may dispose of a bottle of stam yenam, as wasting the wine, which has a monetary value, might be a violation of bal tash’hit? The Maharam Shik rules that since the Rema writes that it is preferable to be strict, it cannot be considered to be bal tash’hit.
Summary: One may not drink stam yenam. Sephardic practice, according to Maran, is to prohibit deriving any benefit from stam yenam as well, including selling, or even giving the wine as a gift. Ashkenazic practice, based upon Rashi and Rashbam, is to permit benefit, although the Rema writes that “it is better to be stringent.” Therefore, Sepharadim may not sell, or return a non-kosher bottle of wine which they received as a gift, nor may it be given to anon-Jew as a present. However, the Rema adds that even according to Ashkenazi practice, one is not allowed to buy and sell non-kosher wines for business, and therefore all would agree that non-Jews should not sell non-kosher wines.