GARMSIR, Afghanistan — The United States spent more than $7 billion in the past 14 years to fight the runaway poppy production that has made Afghan opium the world’s biggest brand. Tens of billions more went to governance programs to stem corruption and train a credible police force. Countless more dollars and thousands of lives were lost on the main thrust of the war: to put the Afghan government in charge of district centers and to instill rule of law.

But here in one of the few corners of Helmand Province that is peaceful and in firm government control, the green stalks and swollen bulbs of opium were growing thick and high within eyeshot of official buildings during the past poppy season — signs of a local narco-state administered directly by government officials.

In the district of Garmsir, poppy cultivation not only is tolerated, but is a source of money that the local government depends on. Officials have imposed a tax on farmers practically identical to the one the Taliban use in places they control.

Some of the revenue is kicked up the chain, all the way to officials in Kabul, the capital, ensuring that the local authorities maintain support from higher-ups and keeping the opium growing. And Garmsir is just one example of official involvement in the drug trade.