In Baiji, dozens of active insurgent groups feed off corruption from the refinery, said Lt. Ali Shakir, the commander of the paramilitary Iraqi police unit here. “If I give you all the names, your hand is going to be tired” from writing them down, he said.

Image American troops at the Baiji refinery. Credit... Eros Hoagland for The New York Times

Lieutenant Shakir said the more hard-core insurgent groups had a lot of money to pay other fighters, and he grumbled that part of the reason they thrived was that obvious thievery was never prosecuted.

Another scheme, he said, involves a trucking company owned by a man tied to the insurgency who is also a relative of Baiji’s mayor. The trucks take fuel from the refinery but are then unloaded just south of Tikrit. Making arrests would be a waste of time, he said, because provincial officials would let the perpetrators go.

“What can I do?” he said. “After a half hour, they would be released.”

Last year, the Pentagon estimated that as much as 70 percent of the Baiji refinery’s production, or $2 billion in fuels like gasoline, kerosene and diesel, disappeared annually into the black market. Baiji supplies eight provinces.

Some of the most obvious corruption and theft, like tanker trucks hijacked at gunpoint from distribution pumps, has been curbed by Captain Da Silva and his predecessors. The American troops live inside the compound.

Moreover, American officials say they believe that in recent weeks, some illicit profits flowing from the refinery have diminished. The refinery has been operating at almost full capacity, they say, pouring more fuel on the market and narrowing the spread between government-mandated rates for fuel and what it fetches on the black market.

Exploiting that spread is one key to illicit profits from the refinery. For example, in January a tanker filled with kerosene that was supposed to be worth about $10,000 was going for $19,000 in Baiji, according to surveys of black market prices for the American military. In Samarra, it cost $35,000, a result of what soldiers described as the former mayor’s efforts to manipulate fuel prices.