Despite sanctions and trade embargoes, over the past decade the United States government has allowed American companies to do billions of dollars in business with Iran and other countries blacklisted as state sponsors of terrorism, an examination by The New York Times has found.

At the behest of a host of companies — from Kraft Food and Pepsi to some of the nation’s largest banks — a little-known office of the Treasury Department has granted nearly 10,000 licenses for deals involving countries that have been cast into economic purgatory, beyond the reach of American business.

Most of the licenses were approved under a decade-old law mandating that agricultural and medical humanitarian aid be exempted from sanctions. But the law, pushed by the farm lobby and other industry groups, was written so broadly that allowable humanitarian aid has included cigarettes, Wrigley’s gum, Louisiana hot sauce, weight-loss remedies, body-building supplements and sports rehabilitation equipment sold to the institute that trains Iran’s Olympic athletes.

Hundreds of other licenses were approved because they passed a litmus test: They were deemed to serve American foreign policy goals. And many clearly do, among them deals to provide famine relief in North Korea or to improve Internet connections — and nurture democracy — in Iran. But the examination also found cases in which the foreign-policy benefits were considerably less clear.