U.S. Secretary of State John F. Kerry, right, speaks next to Afghan presidential candidates Ashraf Ghani, center, and Abdullah Abdullah during Friday’s news conference in Kabul. (Omar Sobhani/Reuters)

After weeks of partisan bickering, Afghanistan’s two presidential rivals formally pledged Friday to speed up an audit of the disputed June 14 runoff election, respect the results and form a joint government as soon as possible, with the winner becoming president and the loser acting as a chief executive.

The joint declaration, announced here by candidates Abdullah Abdullah and Ashraf Ghani with Secretary of State John F. Kerry standing at their side, sounded a lot like the promise the two men made three weeks ago, when Kerry flew here and brokered a political deal to save Afghanistan’s election process from collapse.

But this time, the occasion appeared to be marked by a greater sense of urgency and shared commitment on the part of the candidates, whose disputes over details of the power-sharing plan and the vote recount had threatened to derail the process again. Ghani officially won the June election, but Abdullah charged that the results were marred by massive fraud.

“We are working for a shared goal, and we are committed to working together for the sake and the interests of Afghanistan,” ­Abdullah, a former foreign minister, said at a news conference with Ghani and Kerry. “One will win, and the other will be second, but we will have full cooperation.”

Ghani, a former finance minister, spoke of their joint “historic responsibility” to the country and said it was crucial to replace the current “dangerous uncertainty” with a concrete plan for the future. “We trust each other,” he said, looking at Abdullah. “What unites us now is far greater than what divided us during the campaign.”

The agreement signed by the two men was short on specifics, but both said they would appoint commissions to deal with an array of issues as the audit concludes and a government is formed. Ghani refused to sign the original Kerry-backed agreement, reportedly because he expected to win and did not want to give Abdullah too much power. On Friday, he signed a similar declaration and said they both would work on “the best division of labor.”

The two also said they hoped the recount would be finished and a new president inaugurated by the end of the month, in time for him to attend a NATO summit in early September. Some observers, however, believe the slow audit of 8.1 million ballots makes that an unrealistic goal.

Although Kerry played a more low-key role during this second visit and praised the two leaders for embarking on their own “Afghan road map,” he and U.N. officials met privately with both men and reportedly conveyed their growing impatience for a new president to be installed.

The new president was originally scheduled to be inaugurated last weekend, but now it is not clear how soon that can happen. The NATO summit would be a crucial opportunity for a new Afghan government to secure aid commitments, and the future role of U.S. troops here depends on a bilateral security agreement that awaits the new president’s signature.

In their public statements, both candidates spoke of the need to put the divisive election behind them and start afresh. “It is time to turn a vicious cycle into a virtuous cycle,” Ghani said. Abdullah described their new plans as a “win-win” situation for the country.

Nevertheless, questions remain about whether the two can control their rogue supporters and find ways to compromise between the need for reforms and the Afghan “winner-take-all” tradition, in which elected leaders parcel out patronage to ethnic and regional backers. Abdullah is beholden to some powerful former militia leaders who have threatened to cause trouble if he loses the recount.