ISLAMABAD, Pakistan — Just a day ago, Afghan officials were concerned that U.S. officials would make a too-hasty agreement with Taliban insurgents and potentially undermine the country’s security and democratic gains after 17 years of civilian rule.

But by Friday morning, the government of President Ashraf Ghani was reeling from a much more concrete development: the news that President Trump was suddenly considering a plan to withdraw half of the 14,000 U.S. troops stationed in Afghanistan.

Aides to Ghani, scrambling to fashion a face-saving response, attempted to portray a potential massive reversal of U.S. military policy as no big deal, even as many observers in Afghanistan and elsewhere expressed growing alarm.

Shortly after noon, Harun Chakhansuri, a top spokesman for Ghani, said on an Afghan TV news station that such a drawdown would have no major impact on Afghanistan’s ability to defend itself. He said most of the U.S. forces likely to be withdrawn “are engaged in a training and advising mission for Afghan forces, and Afghan forces are capable of defending the country.”

Several hours later, Fazl Fazili, another aide to Ghani, echoed that assessment, tweeting that the departure of a “few thousand” foreign military advisers would not affect Afghan security. In a second tweet, he said that since 2014, when most U.S. combat forces left the country, those who predicted a military collapse were proven wrong, and “our brave defense & security forces . . . defended the nation with great valor.”

The optimistic comments contrasted sharply with the alarmed reactions and dire predictions Friday of analysts, former officials and political figures in Afghanistan and neighboring Pakistan.

In both countries, a variety of observers said they feared that a sudden unilateral pullback of U.S. troops could usher in a period of political instability, give the Taliban insurgents extra power at the negotiating table or sabotage the peace talks entirely, and leave Afghanistan more vulnerable to violence and terrorist attacks.

Many drew comparisons to the United States’ inattention to Afghanistan after the end of Soviet military occupation in 1989, which led to a government collapse in Kabul, a destructive civil war among ethnic militias and a huge exodus of refugees.

“A U.S. military drawdown will strengthen the Taliban’s position in the peace negotiations and precipitate political chaos in Kabul,” putting a constitutional transfer of power through elections in doubt, said Haroon Mir, a political analyst in the Afghan capital. Regional powers will again jockey for influence, but none will be able to “fill the political or economic vacuum left after a U.S. exit,” he said. “Ultimately, history will repeat itself.”

 The Afghan security forces have continued to struggle with numerous problems, including high-level corruption and low reenlistment rates, despite extra help from U.S. advisers sent in last year. Afghan soldiers and police have suffered record-high casualties this year as Taliban forces have attacked aggressively in numerous areas of the country.  

Naqi Farooqi, 24, an unemployed law school graduate in Kabul, said he feared that the pullback of U.S. forces would allow the return of Taliban rule and the shutting down of social and press freedoms, which the country has enjoyed since the Taliban regime was overthrown in 2001.

“The Taliban will come if the U.S. troops withdraw,” said Farooqi, who was waiting with friends for an Indian film showing at a movie theater. “People do not want the Taliban back. The U.S. forces should stay longer until Afghanistan can stand on its feet, economically and militarily,” he said.

In Pakistan, a senior official at the Foreign Ministry offered an almost identical view to that of Mir, adding that Pakistan could face an additional burden if political turmoil or insecurity were to send a new wave of Afghans fleeing across the border. He spoke on the condition of anonymity because he was not authorized to discuss the topic.

“Any troop withdrawal or major reduction in their number before peace is restored would be a very unwise move,” the official said. “It would bring chaos and disorder, more fighting and perhaps a civil war. He noted that after the United States turned away from Afghanistan in 1989, “Pakistan, too, had to bear the brunt of what happened” amid the turmoil that followed. “We would not like to see a repeat of that.”

Mushahid Hussain, chairman of Pakistan’s Senate Foreign Relations Committee, said a U.S. troop drawdown would be “an admission of defeat in America’s longest war” and “the biggest military setback for the U.S.” since the fall of Saigon in 1975. He said it would increase Washington’s dependence on Pakistan as a force for peace in Afghanistan and could lead to a postponement of Afghan elections “to pave the way” for a broad unity government including the Taliban.

Until recently, U.S. officials have accused Pakistan of paying lip service to peace talks while harboring anti-Afghan Taliban militia forces. But in recent months, under a new prime minister, Pakistan has worked to convince the United States of its sincere interest in peace and sent representatives to talks last week in the United Arab Emirates with U.S., Saudi and Taliban delegations.

Observers in Afghanistan and Pakistan said they could not understand why Trump would suddenly decide to withdraw thousands of troops at a time when negotiations were finally beginning to gain traction. The Taliban has long demanded a total departure of U.S. forces, but many other issues are on the table, and the insurgents seemed to show their seriousness by sending an unusually senior group to the UAE talks.

Amrullah Saleh, a former chief of the Afghan intelligence agency, said in an email that Trump’s plan to cut back troops shows that he sees Afghanistan as a “burden, not a strategic and necessary ally.” He said there has been “no progress” in peace talks and “no sign” of Pakistan halting support to the Taliban, and that now the country faces an added threat of diminished U.S. military assistance.

“Maybe it will be the end for the U.S., but a bitter beginning for us,” he said.

Constable reported from Islamabad. Sayed Salahuddin and Sharif Hassan in Kabul and Shaiq Hussain in Islamabad contributed to this report.