KABUL, Afghanistan — Afghanistan’s president, Ashraf Ghani, appeared increasingly trapped in recent months in a demoralizing swim against the political tides — until President Trump, inadvertently, tossed him a lifeline.
Mr. Ghani, in pursuit of a second five-year term, had pushed for presidential elections later this month. But the only game in town that seemed to matter was the high-energy American push for a deal with the Taliban that could end the 18-year United States military presence and, ultimately, bring the Afghan sides into a power-sharing arrangement.
Not only was Mr. Ghani’s government largely left out of the initial peace efforts, a deal would almost certainly have meant the end of his time at the palace, at least for the time being, given the likelihood that a transitional government would be put in place.
Then, just when Mr. Ghani’s aides appeared to be running out of options, their bags packed for a Camp David meeting meant to complete the American agreement with the Taliban, President Trump pulled the plug on the talks. All of a sudden, the elections were back in the front seat, seemingly certain to take place on Sept. 28, with Mr. Ghani one of the favorites.
The sudden change of fortune for Mr. Ghani in no way means easier times ahead for Afghanistan, even if the interruption of the peace efforts is seen by many of its critics as an opportunity for course correction. Mr. Trump has suggested he might go ahead with withdrawing troops even without a deal.
There is little doubt that violence, already taking dozens of lives daily, will now intensify, and the Taliban have vowed to target the elections. On any given day, there is fighting in nearly two dozen of the country’s 34 provinces, and the insurgents threaten several cities. About 2,000 of the country’s 7,000 polling centers will remain shut because they cannot be secured.
“We are concerned about the security situation, and that is the biggest issue,” said Abdul Aziz Ibrahimi, the spokesman for Afghanistan’s election commission. “We are in touch with the Afghan security institutions, and they are committed to providing the election security.”
The insecurity not only makes campaigning difficult, but also deters voters from turning out.
“There are a lot of explosions and a lot of fear among the people,” said Obaidullah Abid, a resident of the eastern city of Jalalabad. “I will see — if the situation is a little better, I will come out to vote. Otherwise I will stay home. For me, my life is more important than a vote.”
The candidates seem to feel the same, and the result has been a presidential race that little resembles one.
For the first month of campaigning, the candidates barely held rallies, not just out of concern about attacks but because the election process felt hostage to the peace efforts. Except for a half-dozen events, Mr. Ghani was reduced to addressing “virtual rallies” across the country via video-chat. His main rival, Abdullah Abdullah, was largely meeting smaller groups at his home.
Even though campaigning is in full swing now, security, and the fear of mass-casualty bombings, is likely to prevent large gatherings.
The vote itself will be a major challenge for the country, where elections have resulted in disputes that dragged on for months. And while resuscitating the peace process after Mr. Trump’s abrupt decision to end it could take a while, it may be even further delayed if there is a serious election dispute.
In 2014, a stalemate between Mr. Ghani and Mr. Abdullah over the results of the fraudulent presidential elections threatened to tear the country apart. John Kerry, the American secretary of state at the time, negotiated a power-sharing deal that made Mr. Ghani president and Mr. Abdullah the government’s chief executive, a new role equivalent to prime minister.
Western officials hope the recent sentencing of 10 former election commissioners over irregularities in a messy parliamentary vote last fall, and the introduction of biometric verification measures for voters, will help reduce large-scale fraud.
Although there are about 16 candidates running this time, the race, once again, appears to be largely between Mr. Ghani and Mr. Abdullah.
Mr. Ghani has replaced his problematic vice president, Gen. Abdul Rashid Dostum, who is accused of abducting and sexually assaulting a political opponent while he was vice president. In his stead, he has brought a younger running-mate, the former intelligence chief Amrullah Saleh.
“We will win, first round,” Mr. Saleh said. “We have already won in the perceptions. It’s only a matter of engraving it in reality.”
Mr. Saleh said what distinguished their ticket from their opponent’s was their “solid, independent Afghan position in the peace process” and an agenda for strengthening the state institutions in the face of both Taliban attacks and of ingrained patronage networks of strongmen. Mr. Abdullah, he said, has built a coalition of “complaints and criticism” without a narrative.
“The country is thirsty for freshness,” said Mr. Saleh, who barely escaped a deadly attack on his office the day the campaign began. “The country is fed up with an enriched class of brokers who do not deliver.”
Mr. Abdullah, backed by a large coalition including many of the strongmen Mr. Ghani has alienated, is casting himself as the man anyone can work with. During the five years of his joint government with Mr. Ghani, he embraced those strongmen, including General Dostum, that the president angered. Now he is trying to turn that into votes.
Fraidoon Khwazoon, a spokesman for Mr. Abdullah, said the “political and jihadi leaders” who are backing their ticket have long been seen as “the cards you need for victory.” Mr. Ghani has alienated them at a time when they still carry support in society.
Mr. Khwazoon, too, said his candidate would win the first round.
“Afghanistan cannot be led through dictatorial ways and through impatience,” he said, contrasting his candidate with Mr. Ghani, who has a reputation for imperiousness. “For leading Afghanistan you need someone who has vast patience, who can accept criticism and engage in consultations. Dr. Abdullah has these characteristics, and the political leaders realize that.”
Other candidates in the race include Rahmatullah Nabil, a former intelligence chief and a strong critic of the current government, and Gulbuddin Hekmatyar, a former militant who reconciled with the government in 2017.
Mr. Nabil has tried to take aim at both the current leaders of the government, saying they have failed their test and have polarized the country.
“We have all become prey to prejudice and ethnic politics,” Mr. Nabil said at his campaign launch. “On a daily basis, prejudice explodes in the minds of our youth just like the suicide bombings.”
Many observers fear that a dispute is looming because Mr. Ghani’s team has a sense that it is entitled to a second term in office. Mr. Abdullah, who has said Mr. Ghani stole the 2014 election, is allying with people who have deep grievances against Mr. Ghani and who will not let go easily.
On Tuesday, campaigning for Mr. Ghani largely consisted of going from one small event to the next at a new campaign headquarters in Kabul.
Security forces blocked the streets around the complex, set behind blast walls bearing large murals of him and patrolled by armed guards and bomb-detection dogs. Visitors were required to pass through several layers of security, with each event space cordoned off by high walls and more security guards.
Mr. Ghani, trailed by elite guards dressed in dark suits and carrying automatic weapons, walked briskly from event to event. His security detail struggled at times to keep up with him as he shook hands with bystanders, and the president alarmed the guards when he pushed past his own security bubble.
Mr. Ghani delivered short, vigorous speeches to various constituencies — to young people and to elders from Nangarhar and Paktika Provinces inside separate tents, shaded from the sun, and to smartly dressed businesswomen in an air-conditioned meeting room inside a refurbished office tower that opened just last week.
“The Afghan people want peace, and I am ready to sacrifice anything, even my life, for it — but not the Islamic Republic of Afghanistan, not the Afghan security forces, not women’s rights,” Mr. Ghani told one of the groups, stressing the democratic system in the face of Taliban’s theocratic vision of governance. “You are not voting for the next five years. You are voting for the next five generations.”