WASHINGTON — The Afghan government has clashed with President Donald Trump's envoy over a proposed troop withdrawal deal with the Taliban, just as Washington is preparing to unveil the agreement, foreign diplomats, Afghan officials and former U.S. officials said.

Afghan officials and U.S. special envoy Zalmay Khalilzad had tense exchanges in Kabul over the past few days after the American diplomat briefed President Ashraf Ghani and his advisers on the proposed deal with the Taliban, a foreign diplomat and two former U.S. officials said.

Ghani's government responded to the briefing "badly" and the discussions were marked by "raging arguments," said one foreign diplomat familiar with the talks.

The State Department declined to comment on the discussions in Kabul or on details of the proposed U.S.-Taliban deal.

The proposed agreement "in principle" with the Taliban would see the phased withdrawal of U.S. troops in return for the Taliban agreeing to enter into peace talks with the Afghan government and pledging not to allow areas under their control to be used as a launching pad for al Qaeda, Islamic State or other terrorist groups. Khalilzad said this week that if the agreement is approved by President Trump, the United States would initially pull out about 5,000 troops in 135 days.

The Afghan government, which has long been wary of the U.S.-Taliban talks and was never invited to take part, worries that American troops could be withdrawn before a peace agreement is firmly in place and that Washington may have made too many concessions to their adversaries, foreign diplomats and Afghan officials said.

"The concerns are very high, not just for the government but also for the people of Afghanistan, because the people of Afghanistan have been bitten by this snake before," Waheed Omer, a senior adviser to the Afghan president, told a press briefing in Kabul on Thursday.

Download the NBC News app for breaking news

"We are still not assured of what the agreement's consequences could have for Afghanistan's future," Omer said. "Our position is that we need more debate on this agreement."

State Department officials said that on Thursday Khalilzad flew to the Qatari capital of Doha, where he has previously held talks with the Taliban. The Taliban maintain a political office in Qatar.

It was unclear if Khalilzad would attempt to secure substantial changes to the deal, which follows nearly a year of unprecedented negotiations between the Taliban and the United States.

To reassure the Afghan government, the U.S. is considering a separate joint statement or declaration that would make clear existing bilateral agreements between the two countries would remain in effect, according to a foreign diplomat and a U.S. source familiar with the matter. In addition, the Afghan government would acknowledge — but not endorse — the U.S.-Taliban deal, the sources said.

If the Taliban deal enters into force, the Taliban and the Afghan government would start peace talks in Oslo later this month.

But a major sticking point is President Ghani's vow to hold elections as scheduled on Sept. 28, which some Western governments worry could cause more political turmoil and leave Afghan negotiators divided as they try to hammer out a peace accord with the Taliban. Some of Ghani's political rivals also oppose going ahead with the polls.

The talks with the Afghan government this week coincided with a series of deadly attacks, including a suicide bombing in Kabul on Monday and a bombing Thursday near an Afghan intelligence office that killed 10 civilians and two NATO service members, a Romanian and an American.

The Trump administration has offered few details about the Taliban talks and has rarely explained its approach publicly. Khalilzad, who struck an optimistic note earlier this week, faces increasing criticism over the negotiations from both ends of the political spectrum, including from conservative commentators, former military commanders and diplomats and U.S. lawmakers.

Rep. Eliot Engel, D-N.Y., the chairman of the House Foreign Affairs Committee, accused the State Department on Thursday of stonewalling Congress and failing to keep the public informed about negotiations aimed at ending America's longest war.

Engel, in a letter to Khalilzad, demanded the envoy testify before the committee "so that Congress and the American people will have the long-overdue opportunity to understand the contours of your negotiations with the Taliban and the potential risks and opportunities that may result."

Sen. Lindsey Graham, R-S.C., often an outspoken ally of President Trump, has warned against a total pullout of U.S. troops and said he plans to push for legislation that would require the administration to certify that a drawdown of American forces does not jeopardize U.S. national security.

Skeptics of the Taliban talks have charged the Trump administration with backing away from tougher positions over the past several months, including an earlier insistence on ensuring the Taliban agree to a countrywide ceasefire. Now U.S. officials say a ceasefire will be worked out between the Afghan government and the Taliban in the first stage of peace talks, according to foreign diplomats.

There are currently about 14,000 U.S. troops in Afghanistan, advising Afghan forces and carrying out counter-terrorism operations against al Qaeda and ISIS militants. The U.S. military has had boots on the ground since 2001, when American forces toppled the Taliban regime for harboring the al Qaeda extremists behind the Sept. 11 attacks.