A pair of recent elections, both coincidentally in mainly Muslim countries, yielded results that have been contested by the contenders, albeit with somewhat different potential consequences.

In Indonesia, the world’s most populous Muslim country and third largest democracy, former general Prabowo Subianto refused to accept that he had been soundly thrashed by a relative upstart, Joko Widodo, and “withdrew” from the vote-counting process once it became clear that the surge in support that had come his way in June would not suffice to propel him into the presidency.

His advisers toyed with the idea of an appeal to the constitutional court, but at least some of them appeared to realize that the voting gap of about eight million was too wide to be recognized as fraudulent. Besides, the anecdotal evidence mostly pointed to democracy-defying feats on the part of Prabowo’s supporters, rather than those of the man popularly known as Jokowi.

In fact, until last month there was cause to presume that the presidential election would be almost a cakewalk for Joko, the governor of Jakarta, whose approach to governance had heightened his popular appeal.

Meanwhile in Afghanistan, the mid-June run-off electoral contest between Abdullah Abdullah (who long ago duplicated his name when culturally confused foreign correspondents expressed dissatisfaction with a solitary moniker) and Ashraf Ghani led to both of them claiming a lead before the counting had even begun.

Abdullah had emerged as the clear frontrunner in the first round of polling in April, with about 45 percent of votes, compared with 31.5 percent for Ghani. It is hardly surprising, then, that he and his supporters were taken aback when Abdullah’s proportion of the vote actually fell in last month’s second round, going by the preliminary results, while Ghani’s tally doubled from 2.1 million to 4.5 million votes, ostensibly crowning him as the successor to Hamid Karzai, who was ensconced in power nearly 13 years ago by the US-led military occupiers.

The prospect of a grab for power by Abdullah’s supporters brought the US Secretary of State John Kerry scurrying to Kabul, where he struggled, with some success, to hammer out a deal whereby the losing candidate would be able to nominate a chief executive — effectively a prime ministerial post, eventually to be designated as such — following an audited recount of the second round votes.

Just a few days later, representatives of the two candidates clashed over which votes ought to be discarded, and it is as yet far from clear that Kerry’s diplomacy will yield the kind of dividends that would enable US to declare a success of sorts by the time most of the interventionist forces are withdrawn by the end of this year (with the remaining troops doomed to another two years of largely futile deployment).

On the face of it, the stakes are considerably higher in Afghanistan than in Indonesia. The latter has done a reasonable job of recovering from more than 30 years of Suharto’s dictatorship.

Prabowo, a former son-in-law of Suharto, indicated a return of sorts to the verities of that unfortunate era and one would like to think he did not make it past the post chiefly on that account, although the substantial proportion of votes he garnered provides cause for reflection. Prabowo was US-trained head of the Kopassus secret forces and associated with enough human rights abuses in East Timor as well as during the popular movement that toppled Suharto to earn him persona non grata status in the US and elsewhere in the West, although the visa ban would, no doubt, have been immediately lifted in the event of his victory, as it was in the case of Narendra Modi.

Joko, who represents the party led by former President Megawati Sukarnoputri, is widely viewed as potentially a refreshing change from the norm, although his Obama-esque demeanor serves as a reminder that the optimism may be premature. Nonetheless, he’s decidedly a better bet than his opponent.

He won’t be taking over until October though, reflecting a US-like distance between a presidential election result and the eventual succession. Which, in turn, serves as a reminder of the unusual instance more than 13 years ago when the outcome of an American presidential election hung, so to speak, on hanging chads, and the supreme court intervened to put an end to a recount in Florida that, if carried out, may well have left the US with a less idiotic head of state and government.

In Afghanistan, too, the two posts have thus far been melded in a single personality, but Kerry and his colleagues have striven to make it not so, despite remonstrations from the Karzai administration, which views the prospect of a parliamentary set-up with trepidation. But then, in the American view, the Karzai experiment has been less than a resounding success.

Karzai’s own re-election in 2009 was beset with controversy, amid compelling accusations of fraud. His primary opponent was Abdullah, who had previously served under him as foreign minister.

This time around, Abdullah’s representatives claim to have heard phone conversations between Ghani aides and election officials referring, inter alia, to “stuffed sheep” (rather than ballot boxes), and there have apparently been instances where entire polling stations unbelievably yielded a 100 percent result in Ghani’s favor.

In Indonesia, it was evidently the loser whose side strayed beyond the bounds of legality in order to secure a victory - which would help to explain his unsporting tantrum this month.

Indonesia, though, will likely pull through the mild crisis with little damage. In Afghanistan, the election result is a relatively small component of the overall picture, and the unseemly allies that both candidates have embraced (one of Ghani’s running mates is the infamous ex-general Abdul Rashid Dostum, while Abdullah too enjoys the support of several warlords) illustrate the jagged contours of the nation’s reality after 45 years of almost ceaseless conflict, with the Taleban lately demonstrating their continued clout as the foreign presence dwindles.

It’s easy enough to extend good wishes to Indonesia. It’ll take more than prayers, though, to see Afghanistan through.