KABUL, Afghanistan — Nearly half of all Afghans want U.S. and NATO troops to leave Afghanistan once a peace deal to end the country’s 18-year war is signed with the Taliban, according to a survey released Thursday.

The Institute of War and Peace Studies also found that an overwhelming 80% of Afghans surveyed said a political solution was the only way to bring about an end to fighting. Twenty percent said a military solution was possible.

The survey found that 46% of Afghans want U.S. and NATO troops out of the country once a deal is struck, while 33% would have them stay.

The survey polled 5,038 Afghans in 34 provinces. It was conducted between Nov. 23-Dec. 20 and has a 5% margin of error. Sixty-one percent of participants answered online with the remaining 39% were interviewed in person.

While 57% of those surveyed wanted the Taliban to evict the foreign fighters among them. Many of those foreigners are believed to have links to al-Qaida and other militant organizations.

Esper says reduction of American forces in Afghanistan relies on a peace agreement with Taliban U.S. Defense Secretary Mark Esper arrived Sunday in Afghanistan, where stalled peace talks with the Taliban and persistent violent attacks by the insurgent group and Islamic State militants have complicated the Trump administration’s pledge to withdraw more than 5,000 American troops.

Washington has been talking directly with the Taliban since September 2018, when the White House appointed Afghan-American Zalmay Khalilzad to start peace talks. The talks are aimed at finding an agreement to end America’s longest conflict and allow the U.S. to bring home its troops.

The survey showed Afghans were divided over the choice of Khalilzad as chief negotiator, with 41% favoring his appointment and 39% opposed. A whopping 20%, however, said they had no opinion.

× Fear of missing out? Sign up for the Early Bird Brief - a daily roundup of military and defense news stories from around the globe. Thanks for signing up. By giving us your email, you are opting in to the Early Bird Brief.

Of the 5,038 Afghans surveyed, 3,274 were men and just 1,764 were women.

A strong 83% of those surveyed said women should be involved in the peace negotiations, while just 17% were opposed.

A peace agreement, which is being negotiated between Khalilzad and Taliban negotiators, will leave it to Afghans on both sides of the conflict to negotiate the face of a post-war Afghanistan. They must decide on constitutional changes enshrining the rights of women, media and free speech. The negotiations will decide the future of Taliban fighters as well as the heavily armed militias belonging to warlords ruling in Kabul.

The majority of Afghans surveyed said they feared their homeland would descend into civil war if America pulls out its troops without first getting a peace deal.

As Afghans contemplate a future without a U.S. military troop presence, in Iraq the killing earlier this month of Iranian Gen. Qassem Soleimani has bolstered Iran’s efforts to see U.S. troops leave Iraq. The withdrawal of American forces from Iraq has been a long-standing goal of Iran’s.

Iran’s support to the Taliban, which has included MANPADS and a bounty on US troops, could be a spoiler for peace in Afghanistan The Quds Force “usually asks the Taliban commanders to send their best fighters for the training, likely due to the more advanced training involved in learning MANPADS systems or possibly to allow these fighters to become future trainers of other Taliban fighters inside Afghanistan.”

Meanwhile, Taliban fighters took responsibility Thursday for the ambush and killing of an Afghan intelligence official in southern Helmand province.

The officer, who headed the intelligence department’s press office for the province, was ambushed late Wednesday, according to provincial police chief spokesman Zaman Hamdard.

In the country’s north, a roadside bomb killed a military commander and his bodyguard early Wednesday.

The attack in northern Faryab province killed the commandeer of the Afghan army’s 1st Battalion and his bodyguard and wounded two other bodyguards.

The Taliban control or hold sway over roughly half of Afghanistan and continue to stage near-daily attacks targeting Afghan and U.S. forces, Kabul government officials or those seen as linked to the government. That’s the case even as they hold peace talks with the U.S. and have given the U.S. envoy a document outlining their offer for a temporary cease-fire in Afghanistan.

Associated Press writer Kathy Gannon in Islamabad contributed to this report