The company led by the American billionaire Koch brothers, along with dozens of banks and fund managers, kept billions of dollars in profit from Bernard L. Madoff’s Ponzi scheme in accounts offshore. As it turns out, that was a good decision.

Koch Industries and others who invested in the Madoff fund from offshore accounts won a key ruling in federal bankruptcy court on Monday, when the judge said certain funds held abroad — estimated at about $2 billion — could not be made available to victims of the Madoff scheme.

The ruling highlights the tug-of-war that has been raging between those who lost money when the scheme fell apart eight years ago and those who walked away before the fraud came to light, having recouped their original investments and then some.

Irving H. Picard, the trustee appointed to recover money for the victims, had argued that he should get the money because the investors used so-called feeder funds that operated in the United States even though they were registered offshore. Those funds gathered investor money on behalf of Mr. Madoff. But Judge Stuart M. Bernstein of Federal Bankruptcy Court in Manhattan said foreign bankruptcy proceedings blocked the trustee from accessing the money.