Here is a fantastic quote from the UN official who worked on this with Kerry:
Whenever there is a need, you are here, and you deliver miracles, the UNs Kubis told Kerry on July 12 at a press conference with President Hamid Karzai. Because what we witnessed today, it was not just a top-notch diplomatic achievement; it was close to a miracle.
Kerry's comments explain how this goes far beyond just agreeing to a recount. Both sides committed to a unity government where both sides will have their interests represented.
The losing side is likely to have a formal role in the future government, the U.S. official said, speaking on the condition of anonymity because the discussions between the candidates are still confidential. The official declined to confirm a report in the New York Times that the loser would be made a prime minister or that there would be moves to a parliamentary system.
<snip>
The United States supports a sovereign, unified, and democratic Afghanistan, and our commitment to that future is absolutely clear, Kerry said on July 12. Our partnership with the Afghan people is strong, and together we have determined that the long, hard road ahead is going to bring us to a better place.
<snip>
They are working within the constitutional process to readdress grievances, urging restraint among their supporters, and refraining from any actions that could tear the country apart rather than help bring it together, which they are doing tonight, Kerry said on July 12. That is what patriotism requires, and I will tell you that both Dr. Ghani and Dr. Abdullah are proud Afghan patriots.
http://www.bloomberg.com/news/2014-07-13/kerry-saves-u-s-s-afghanistan-investment-with-vote-deal.html
--- I guess skills developed over years of trying to get Republicans and Democrats to work together were well used. It really is promising that they are speaking together.