KABUL, Afghanistan — When the White House ordered American diplomats this summer to engage the Taliban directly in the hopes of jump-starting an Afghan peace process, many in Afghanistan welcomed it as a vital first step in trying to break the stalemate that dominates the 17-year war here.

Publicly, President Ashraf Ghani was among them, projecting a measured tone. But officials say that in private, the Afghan leader repeatedly expressed concern and resistance to American officials about the prospect of talks that did not include his government.

They say his concern was that such talks, which the Taliban have insisted should not include the Afghan government, could become a fatal marginalization of the country’s leadership at a hazardous moment.

Last week, Mr. Ghani’s fears came true, in a humiliating way that he had worked to avoid.

The American special envoy, Zalmay Khalilzad, just days after hearing Mr. Ghani’s concerns in Kabul, the Afghan capital, flew to the gulf state of Qatar and quietly met with Taliban representatives. Mr. Ghani and his government heard of that meeting only through news reports, and found out further details not through his American allies — even after he asked — but through a Taliban statement, according to several officials with detailed knowledge of the developments.