Afghan presidential candidate Ashraf Ghani (L) speaks as opponent Abdullah Abdullah looks on during a joint press conference at the United Nations Compound in Kabul. (Wakil Kohsar/AFP/Getty Images)

AFGHANISTAN IS teetering between a political implosion that could ignite civil war in Kabul and a power-sharing deal that could give the country another chance for stability. Election authorities will soon announce the results of a disputed presidential runoff, with former finance minister Ashraf Ghani almost certain to be declared the winner. That means time is running out for Mr. Ghani and opponent Abdullah Abdullah to complete a promised agreement on a “unity government” in which they would share power.

In a phone interview Wednesday, Mr. Ghani said that, while he and Mr. Abdullah had made progress in working out the terms of the prospective administration, there were “a couple of substantial remaining issues.” He added that “the next 24 to 48 hours are going to be decisive.” It will be a tragedy for Afghanistan, and an indictment of both men, if they are not able to complete a deal.

In theory, it should not be too difficult. Both Mr. Ghani and Mr. Abdullah are well-educated, pro-Western moderates who served together during the first government of outgoing President Hamid Karzai. “We are able to work together pragmatically,” Mr. Ghani said. They both support signing a crucial agreement with the Obama administration that would allow U.S. military trainers and counterterrorism forces to remain in the country after this year.

However, the two leaders embody Afghanistan’s ethnic and geographical fault lines. Mr. Ghani is a Pashtun who won strong support in the country’s east and south — including, unfortunately, through ballot-box stuffing. Mr. Abdullah has the backing of northern Afghanistan’s Tajik and Hazara communities. The winner of the presidential election’s first round, Mr. Abdullah believes that Mr. Ghani benefited from massive fraud orchestrated by the Karzai government and that the rigging has not been fully reversed by a United Nations audit.

That divide means, as Mr. Ghani acknowledged, that “a policy of winner-take-all will not work.” He said that the two sides have agreed on a formula for a new government position of “chief executive officer,” who will be responsible for implementing policies and will chair a new council of ministers. The CEO — presumably Mr. Abdullah or his designee — would report to the president and his cabinet but would also be “engaged as a participant in making decisions.” “It’s a considerable package of authority,” Mr. Ghani told us.

That certainly sounds like substantial power-sharing; given the high stakes, the two men ought to find a way to resolve the outstanding details. As Mr. Ghani acknowledged, “This government is not going to have a honeymoon.” The Taliban is on the offensive, winter is coming and uncertainty over the future has left the Kabul government paralyzed. Also bankrupt: Mr. Ghani said that there is a budgetary shortage of more than $900 million, in part because doubts about the government have prompted a collapse in tax and customs collections.

The power-sharing deal between Mr. Ghani and Mr. Abdullah was initially brokered by Secretary of State John Kerry during a July visit to Kabul. But Mr. Kerry is consumed with other crises this week. It is up to Mr. Abdullah and Mr. Ghani to show that Afghanistan can have a future under moderate, pragmatic leaders who are able to compromise.