General Bakhtiar estimated last year that there were 400 to 500 labs in the country, mostly in regions controlled or contested by the Taliban. His forces have destroyed over 100 of them.

But then he admitted, “They can build a lab like this in one day.”

Zabihullah Mujahid, a Taliban spokesman, said the group “had nothing to do” with processing heroin, and denied that major laboratories existed in the areas under its control.

The Taliban have long profited from the opium trade by taxing and providing security for producers and smugglers. But increasingly, the insurgents are directly getting into every stage of the drug business themselves, rivaling some of the major cartels in the region — and in some places becoming indistinguishable from them.

The opium economy in Afghanistan grew to about $3 billion in 2016, almost doubling the previous year’s total and amounting to about 16 percent of the country’s gross domestic product, according to the United Nations Office on Drugs and Crime.

The increase in processing means the Taliban have been able to take a greater share of the $60 billion that the global trade in the Afghan opium crop is estimated to be worth. Demand remains high in Europe and North America: Ninety percent of the heroin on the streets of Canada, and about 85 percent in Britain, can be traced to Afghanistan, the State Department says.

Despite the size of Afghanistan’s opium problem, not much is being done about it. Opium eradication or interception got little attention in the Trump administration’s new strategy for the Afghan war.