From left, Turkmen President Gurbanguly Berdymukhamedov shakes hands with Afghan President Ashraf Ghani, Pakistani Prime Minister Nawaz Sharif and Indian Vice President Hamid Ansari in Ashgabat, Turkmenistan. (Alexander Vershinin/AP)

Afghan President Ashraf Ghani, humiliated over the summer by the collapse of his bold overture to Pakistan to revive peace talks with the Taliban, has met a barrage of criticism at home this month for his new effort to engage Pakistan in the peace process, just when Taliban forces based there have staged a rash of attacks across Afghanistan.

Critics have painted Ghani as kowtowing to his hosts when he was in Islamabad last week, acting out of weakness as his 16-month-old administration flounders on many fronts and bowing to international pressure to make a deal with the neighboring nuclear power that many Afghans think seeks to dominate their country by violence and deception.

But Ghani’s aides and supporters say the president, although frustrated, is determined to find a way to settle the long-running conflict with Taliban militants that has crippled the country’s economy, driven hundreds of thousands of Afghans to flee abroad since Ghani took office and paved the way for more barbaric insurgent groups allied with the Islamic State.

“He feels we have no choice but to engage Pakistan, despite the long history of mistrust between us,” said one private adviser to the president, speaking on the condition of anonymity to talk candidly. “He often says we are not teenagers who can fight and sulk. We have paid too high a price for this undeclared war with Pakistan, and we don’t have the luxury of letting it go on. He will do whatever it takes to end it.”

The urgency of reviving the stalled peace process has been underscored by a surge of violence since October, when the Taliban seized the northern city of Kunduz. Last month, militants beheaded a group of civilians in Zabul province; this month, the group mounted attacks across Helmand province and a deadly siege on the Kandahar city airport. Both provinces border Pakistan.

Reports this week from the Pentagon and the United Nations stressed the deterioration in Afghanistan’s security and the inadequacy of its armed forces to meet the growing threat. The United Nations estimated that control of a quarter of all Afghan districts is “contested” between government forces and the Taliban.

Pakistan’s endorsement is widely seen as the key to any meaningful peace talks, because the Afghan Taliban has long served as its proxy force in a protracted rivalry with neighboring India. In July, Ghani’s attempt to revive the talks fell apart when Pakistan unexpectedly revealed the death of longtime Taliban leader Mohammad Omar, unleashing a power struggle to replace him. Ghani accused Pakistan of treachery.

This time, the atmosphere was markedly different. Pakistan offered an elaborate welcome to Ghani when he visited Islamabad last week to attend a regional conference. Officials there publicly embraced new talks and agreed to several Afghan conditions after Ghani delivered an emotional speech about Taliban butchery and bombings devastating his country.

No specific follow-up plans have been made, though, and it is far from clear whether Taliban leaders will agree to participate. The militants are split among several camps, with some leaders seen as war-weary and eager to talk, and others with more extreme Islamist tendencies moving closer to the Islamic State. A theory circulating widely in Kabul is that Pakistan has a two-track plan to steer weaker Taliban groups to the peace talks while continuing to support more radical fighters.

“Pakistan’s basic policy is still that they want to indirectly control Afghanistan,” said Zalmay Rassoul, a longtime senior national security and foreign policy aide to former president Hamid Karzai. “They now want to use the Taliban to implement a policy through peace that they could not get through war. They want some Taliban to have a share of power in our government, and they want to choose which ones.”

Rassoul praised Ghani for reaching out to Pakistan but added, “I am not optimistic.”

Other Afghans are blunter and darker in their views. Amrullah Saleh, the country’s former intelligence chief, calls Pakistan a “sinister” nation, with an intelligence agency that has long run the Taliban war, that now backs local Islamic State affiliates yet has been continually rewarded with U.S. military and economic aid. Rahmatullah Nabil, the most recent Afghan intelligence head, suddenly resigned last week and issued a harsh statement decrying the ongoing Taliban “slaughter” while Afghan leaders “catwalked” on Pakistan’s red carpet.

Nabil’s embarrassing departure highlighted a broader problem of power struggles, policy splits and lack of leadership within Ghani’s administration at a time of growing insecurity. With parliament balking at many of his appointments, Ghani’s government has no defense minister, no attorney general and now no intelligence chief. Ghani’s office declined to comment for this article and did not provide answers to a list of written questions.

Ghani still enjoys strong Western backing, but he faces an array of domestic problems that have damaged his credibility as a reformer and modernizer while also estranging him from more conservative segments of his Pashtun ethnic group. A surge of human and capital flight has left the economy in dire straits, corruption continues to flourish, and rival groups are plotting to fill the power vacuum.

“President Ghani has become extremely weak, and he has lost most public support,” said Haroon Mir, an analyst in Kabul with longtime links to Abdullah Abdullah, the Afghan chief executive who lost a badly flawed election to Ghani last year. “He is very smart, but he can’t feel the pulse of the people.” As for Ghani’s most recent peace initiative, Mir said, “Peace talks would be nice, but it is a little late. We need to fix a lot of other things first before we can benefit from [talks].”

Still, some analysts said that Ghani’s latest contentious outreach to Pakistan has new reasons to bear fruit. One is Pakistan’s growing economic dependence on investment from China, which has agreed to monitor and promote the peace process. Another is its political instability and religious radicalization — largely a blowback from its sponsorship of Afghan militants — which threaten to divide and isolate the once-moderate Muslim democracy of 180 million.

Moreover, Pakistan has just signed on to a multilateral energy project that Ghani has championed for months — a regional pipeline intended to carry natural gas south from Turkmenistan through Afghanistan to Pakistan and India. During a trip to Turkmenistan last week, Ghani beamed as officials from four neighboring countries signed the agreement, which he hailed as a “historic” step in regional cooperation.

But Ghani’s triumph quickly soured when Pakistani officials said they hoped to enlist the Afghan Taliban to protect the pipeline in areas the group controls.

“This is a critical moment of new opportunities for peace and reconciliation in the region, but the question is whether we can avail ourselves of them,” said Abdul Hakim Mujahid, a member of the High Peace Council set up by the Karzai government to promote peace talks.

“The government can’t defeat the Taliban in battle, and most Afghans support a political settlement, but there are some elements with personal and ethnic interests that would be endangered by peace,” he said. “Unless something is done about that, this moment can be lost.”