KABUL, Afghanistan — The U.S. is talking to the Afghan Taliban, the militant group that sheltered Osama bin Laden as he plotted the 9/11 attacks, about ending America's longest war.

More than 2,400 American troops have been killed in Afghanistan in the 17 years since the U.S.-led invasion toppled the Taliban government. Tens of thousands of civilians have also died in the violence.

President Donald Trump says he wants to withdraw the 14,000 Americans still in the country. About one-third of Afghanistan is now thought to be controlled or contested by the Taliban.

But what would peace with the Taliban look like and what implications might such a deal have? NBC News examines where such an arrangement would leave the fight against international terrorism and Afghanistan's women — cornerstones of American policy after the 2001 invasion.

International terrorism

Senior Taliban officials told NBC News that the group had learned vital lessons about sheltering foreign terrorists.

“This Taliban will give more importance to foreign policy, and they will definitely not provide a safe haven to foreigners,” one senior Taliban member told NBC News on condition of anonymity.

But Waheed Mozhdah, an ex-Taliban foreign ministry official, didn't think a peace deal would play well with the miltant group's rank-and-file.

Mozhdah is a former interpreter for Abdullah Azzam, who mentored bin Laden when Arab fighters flowed into the country to fight the Soviet occupiers in the 1980s. He said many of the ascetic warriors espousing a harsh interpretation of Islam would struggle to accept the existence of the U.S.-backed government in Kabul as well as democratic elections.

“If Taliban [leadership] accept the current government and system, then most of the Taliban fighters will not obey,” said Mozhdah, who now works as an independent political analyst in Kabul. “They will approach and try to join the Islamic State.”

Fawzia Koofi, a legislator from the northeastern province of Badakhshan was cautiously optimistic about talks but warned that a Taliban deal alone would not wipe out extremists.

"I don’t think a ‘peace agreement’ with Taliban will actually result in absolute security and peace in Afghanistan because there are many other terrorist networks including Daesh," she said, using another name for ISIS.

Senior members of the Taliban say Americans have raised the possibility of handing over whole regions of the country or becoming members of the government in exchange for an agreement. NBC News could not independently confirm that claim, and the Taliban is known to have released false information in the past.

Another issue for negotiators will be the Haqqani network, a dreaded militant group that is an integral part of the Taliban. Because of their wealth and deep links to local tribes, one Western diplomat once called the Haqqanis "the Kennedys of the Taliban movement."

As the Taliban's deputy leader, Sirajuddin Haqqani oversees the group's military operations.

The Haqqanis have been behind some of the bloodiest attacks against U.S. troops and civilians in Afghanistan.

They have also been behind a spate of abductions, including that of Army Sgt. Bowe Bergdahl, who was taken after walking off his post in Afghanistan in 2009, and American Caitlan Coleman, her Canadian husband, Joshua Boyle, and their children in 2012. Coleman and her family were rescued in October.

Bergdahl was released in 2014, and sentenced in November to a dishonorable discharge for deserting his post.

The U.S. military presence

NBC News reported last week that impatience with the 17-year war prompted U.S. diplomats and commanders to gamble on a bid to kick-start negotiations, including holding direct talks with the Taliban.

But despite Trump's impatience, President Ashraf Ghani has said Washington and other NATO members will stick with Afghanistan.

“Support will be extended to 2024,” Ghani told Defense One during a NATO meeting in Brussels in July.

Among the questions hanging over a possible peace deal are the Taliban's demands that all foreign troops withdraw from Afghanistan.

However, some experts say that the Taliban knows that the U.S. and other foreign soldiers could be a useful buffer against meddling by regional powers such as Pakistan, Iran, Russia and China.

Economy and aid

The U.S. is spending around $45 billion in aid every year on aid to Afghanistan, but the country remains one of the world's poorest.

Barnett Rubin, a former senior adviser on Afghanistan and Pakistan for the State Department and ex-adviser to the U.N. on Afghanistan, said the U.S. needs to remain engaged to bring stability.

“Afghanistan is the poorest country in the world except for a handful of sub-Saharan countries," he said via email. "If the country cannot pay for schools and teachers, the level of education will decline, and that will have very little to do with a deal with the Taliban. Same for health care."

The Taliban for its part said that these days it is focusing on attracting foreign cash, not fighters.

“The Taliban will invite investors to the country — in mining and in agriculture and also to manage water services,” the senior member of the Taliban said.

Women and girls

Despite the billions in aid, hundreds of thousands of girls are currently not in school, maternal mortality rates are among the highest in the world and more than 80 percent of women have no formal education. But an empowered Taliban with its strict interpretation of Shariah could still have a big impact.

Under its rule, nearly all girls in the country stopped going to school and the vast majority could not leave home unaccompanied by a male relative.

Publicly, Taliban officials say they have changed when it comes to women. Privately, it is often a different story.

“We will never allow women to have jobs in government or the private sector,” the senior Taliban member said via a messaging app.

When NBC News pressed him on the issue of women's rights, he said, “I just read your message here among the members, and they laughed.”

Fawzia Koofi. Rasheed Turkmen / NBC News file

According to Koofi, the lawmaker, the solution is to make sure women on all sides are part of the peace process.

“I would like to see a Talib’s sister or wife, hear their views about education, about going to school, about working,” she said.

Minorities

The Taliban is overwhelmingly composed of Pashtuns — a Sunni Muslim group that has ruled the country for most of its history.

While in power, the Taliban particularly targeted Hazaras — a population that follows Shiite Islam. In 1998, they conducted house-to-house searches to identify and kill Hazaras in the northern province of Balkh. This left thousands dead, according to N.Y.-based Human Rights Watch.

Arif Rahmani, a Hazara member of Parliament, said while peace talks were vital, the Americans should not move too quickly.

"If certain ethnic groups are sidelined in the talks this would not be acceptable to us," he said.

'Freedoms have been immensely curtailed'

Ashley Jackson, a research associate with the Overseas Development Institute think tank, spent months interviewing around 160 officials, fighters and civilians from areas controlled by the Taliban and has a unique perspective on what the group could mean to the population.

Through shadow governments, the group monitors how people dress and how kids wear their hair. If teachers are late or absent, the Taliban dock their pay. They try to enforce rules against radios and smartphones in an effort to control what populations know about the world outside.

“Life under the Taliban right now offers greater security," Jackson said. "They’ve improved upon government services like health care and education by making them less corrupt."

That security stems from the Taliban's control of communities but those who fall foul of its strict rules are punished. Meanwhile, some government areas can be lawless and plagued with criminal or militant violence.

A U.S. soldier arrives at the scene of a suicide car bombing in Kabul in May 2013. Anja Niedringhaus / AP file

But there are losers under the Taliban. In areas the militants have seized, women never leave their homes without a male chaperone, and secondary schooling for girls is practically nonexistent. Women who work outside the home — still a rare occurrence but not unheard of — usually quit or are forced out of their jobs once the Taliban sweeps into town, she says.

While Taliban justice is seen as fair compared with the corruption-riddled, government-run court system, it is also harsh and sometimes violent.

“Ultimately, their freedoms have been immensely curtailed," Jackson added.

Ahmed Mengli reported from Kabul; Mushtaq Yusufzai from Peshawar, Pakistan; and F. Brinley Bruton from London.