KABUL, Afghanistan (CNN) -- Sources close to the discussions in Kabul around the presidential run-off election provided this rundown of Sen. John Kerry's role.
When Sen. John Kerry, D-Massachusetts, arrived in Kabul Friday on a long scheduled visit, he was told by Ambassador Karl Eikenberry at dinner that there was a crisis brewing with President Karzai over the election.
There was a real concern, Eikenberry said, that Afghan President Hamid Karzai was going to denounce the preliminary results based on the Election Complaint Commission's audit showing that Karzai received less than 50 percent of the vote after fraudulent ballots were discounted.
The ambassador told Kerry was very concerned that such a declaration would throw the country into an extended period of uncertainty and severely complicate U.S. efforts in Afghanistan.
After finishing dinner with the troops, Kerry made an unplanned visit to the palace to meet with Karzai at the request of Eikenberry. The meeting lasted for several hours, and in the end, the two men agreed that Kerry would return to the palace early Saturday afternoon.
To accommodate that meeting with Karzai, Kerry cut short a trip to Jalalabad.
Saturday morning, Kerry met with Karzai's chief opponent in the election, Abdullah Abdullah, and U.N. envoy for Afghanistan Kai Eide. Kerry also met again with Eikenberry, along with several international diplomats and others, including French Foreign Minister Bernard Kouchner, the French and British ambassadors and former U.S. Ambassador to Afghanistan Zalmay Khalilzad, who was in the country meeting with Karzai and others to try and resolve the dispute.
Kerry returned to the palace to see President Karzai with Eikenberry. The meeting lasted for about two hours, during which Kerry heard Karzai's concerns that the election had been unfairly taken away from him and that 1.3 million Pashtuns -- the number of disqualified ballots -- had been disenfranchised.
During a one-on-one meeting, Kerry and Karzai discussed the stakes in the election decision and the future of Afghanistan. Kerry also discussed his own poilitical experience with a failed presidential bid, which helped to build a rapport between the two men.
Later that night Kerry returned to the palace for another five hours. The meeting started in a conference room with cabinet members and election experts to discuss methodology for discounting ballots. Eide was present, along with officials from the Election Complaints Commission. That was followed by dinner, where more experts from both the ECC and the International Election Commission were brought in to discuss technical aspects of the process.
After dinner adjourned, Kerry went into another meeting with Karzai where the two agreed to bring the experts back the following morning for further analysis of disputed ballots.
Throughout this whole process Kerry was consulting with Secretary of State Hillary Clinton and Richard Holbrooke, the U.S. Special Representative to Afghanistan and Pakistan.
Sunday morning, Kerry traveled to Kandahar where he met with troops and received briefings on the military campaign. After meeting with some 270 tribal elders at a "tribal shura," he retured to Kabul, where he once again returned to the palace for several hours for dinner and more meetings with Karzai.
The former Democratic presidential candidate did not find Karzai in a positive frame of mind. The Afghan president surprised Kerry and Eikenberry by bringing his own election officials to dinner. The meeting was delayed while the officials from the Election Complaints Commission were summoned. During the break, Kerry met privately with Karzai.
The meeting ended with progress but without resolution, and it was agreed that Kerry would return to Kabul after a planned trip to Pakistan Monday if it was necessary to get the deal done.
In Pakistan on Monday, Kerry had breakfast with General David Petraeus, the chief of U.S. Central Command, and met with the Pakistani president, prime minister and foreign minister as well as the chief of the army and the head of intelligence.
After those meetings, the Massachusetts Democrat cancelled plans to return Washington and returned to Kabul to help finalize the deal, arriving at about 5 p.m. and going straight to palace for further negotiations.
After about two hours, it appeared that a tentative agreement had been reached with Karzai to accept the results of the Election Complaints Commission and agree to a runoff, subject to meetings with his cabinet Tuesday morning. Karzai agrees to announce the agreement early Tuesday afternoon.
Tuesday morning, Kerry and Eikenberry met with Abdullah to encourage him to work together with Karzai in the best interests of the country.
When Kerry returned to the palace at noon, the press conference was substantially delayed. Kerry and Eikenberry worked with Karzai to resolve last minute issues related to certification.
It took close to five hours to finalize the deal. Kerry took a long walk alone with Karzai around the palace, stopping at a mosque where Karzai goes to clear his head.
At 4:50 p.m. the news conference began, Kerry standing by Karzai's side.