KABUL, Afghanistan — Five Afghan police officers were killed by homemade bombs while carrying out a poppy-eradication campaign in western Farah province, officials said Friday, as the government struggles to stem cultivation in a corner of the country where it is on the rise.

Three of the officers died when an improvised explosive device, or IED, buried in the fields exploded Tuesday during the first day of a three-day mission in the Khak-e-Saped district. Another two died Thursday, after a separate explosive planted by the Taliban detonated. In an ensuing firefight with insurgents, nine officers were wounded and four Taliban were killed, officials said.

“The Taliban are protecting the poppy by planting IEDs, and the farmers are supporting them,” said Abdul Rahman Zowandai, a spokesman for the provincial governor.

The symbiotic relationship between the insurgents and poppy farmers boils down to money. Farmers can make far more cash growing poppies than almost any other crop, while insurgents impose lucrative taxes on poppy production, generating an estimated $155 million for the Taliban last year.

Unlimited Digital Access. $1 for 4 weeks.

Eradication is controversial in the aid community. Many organizations see the destruction of crops without financial compensation as flawed policy.

“Opium eradication is never the solution,” said Jean-Luc Lemahieu, the chief of the U.N. Office on Drugs and Crime for Afghanistan. “It’s a blunt instrument, and if it is not connected to altered livelihoods it proves not sustainable and often times arbitrary.”

The eradication program is also dangerous. Last year, 102 Afghan police officers, soldiers and civilians were killed in attacks, and another 127 were injured.

The government’s efforts to combat cultivation have been mixed, partly because areas where production is flourishing tend to be less secure. Corruption also stymies efforts to crack down, as the profits from trafficking help finance political patronage networks.

While cultivation has dropped nationwide since its 2007 peak, between 2011 and 2012, it grew by 18 percent, fueled by a mix of high opium prices and growing instability in parts of the country.

Farah, a province that borders Iran, is one of six provinces where the United Nations expects to see an increase in poppy cultivation. Farmers there cultivate more poppy than anywhere else in the country except for the hotbeds of Helmand and Kandahar.

One challenge the government faces is how to give farmers incentives to grow legal crops. Opium is far more lucrative. In Helmand, the government conducted a two-pronged strategy of eradication and assistance, handing farmers high-quality seeds to replace their opium.