A last-minute change of the agenda and the refusal by Uganda, Djibouti and Burundi to vote for Kenya were Monday evening blamed for the defeat of Kenya's Foreign Affairs Cabinet Secretary Amina Mohamed in the race to become chairperson of African Union Commission.
Details of the shock trouncing in Addis Ababa on Monday afternoon emerged as Kenyan diplomats came to terms with the loss after an extensive campaign of three months that cost the country about $3.5 million.
Ms Mohamed lost to Chad's Moussa Faki Mahamat after seven rounds of voting.
The Chadian foreign minister, who had said he would take a bullet for the sake of Africa, became the fourth AUC chairperson from francophone Africa out of five heads since 2002.
Shortly after the vote, he said he did not have "a magic wand" to right the problems the AU is facing -- such as shortage of funds and slow responses to crises -- saying, instead, that he needed everyone on board to help bring the continent together.
"We will need to get our priorities right. It is a problem, really, because we have not been able to run our organisation properly. We need to come together more than before," he said.
Mr Mahamat will be deputised by Thomas Kwesi Quartey of Ghana.
Ms Mohamed (55) and Mr Mahamat (56) enjoyed significant support from their regions.
The Chadian was declared the winner after garnering 38 votes in the seventh round.
Fifteen countries from the southern Africa bloc, SADC, abstained.
"We congratulate him on a race well won," said Kenya's State House spokesman Manoah Esipisu soon after news of the election results spread from the hall in Addis Ababa.
"We pledge to work with him to defend the pan-African agenda of integration of Africa as well as democracy."
Mr Esipisu continued that he did "not think there is anyone (in Kenya) who cannot be disappointed with this result" and thanked Ms Mohamed "for giving a strong showing".
But the story of Kenya's defeat, really, started sometime in the afternoon when Morocco, which had been lobbying to be accepted back in the AU family after three decades out, successfully argued for the debate about its readmission to be postponed.
That meant that the politics surrounding the race would not be mixed with Morocco's application.
Morocco had quit the AU's predecessor, the Organisation of African Unity, after it admitted the Sahrawi Arab Republic as a member.
This time, however, the North African country had come back with a clear agenda, promising financial goodies to member states who would accept to kick Sahrawi out of the AU while at the same time allowing Rabat back.
So important was the outcome of the Addis vote to Morocco that, on Sunday, the country's foreign minister, Mr Salaheddine Mezoua, hosted a dinner in honour of Mr Mahamat, whom Rabat felt would dance to its tune if elected.
With Morocco's readmission agenda out of the way, delegates had nothing much to do other than concentrate on lobbying and voting.
During earlier lobbying, Ms Mohamed had been endorsed by eastern African countries, but these pledges were not honoured at the ballot.
Uganda, Djibouti and Burundi voted for Kenya in round 1, helping Ms Mohamed get 16 votes against Mahamat's 14.
The rest of the votes were split between Botswana and Equatorial Guinea.
In the second round, however, Chad scored 21, Kenya gained just one more vote, and the rest went to the three tailing candidates.
Mr Mahamat, a father of six, extended his lead in the third round of voting, getting 24 votes against Ms Mohamed's 17. Kenya's neighbours had decamped.
Kenya gained some momentum from round four, getting 26 against Chad's 25 after the other candidates were compelled to drop out.
When the vote entered round 5, one country abstained, but Kenya won with 27 votes against Chad's 26.
The vote entered round six and Chad gained again, collecting 28 votes against 25 for Kenya.
Ms Mohamed had, technically, been defeated, and Mr Mahamat went ahead to garner 38 votes when he ran alone in the seventh round.
The entire SADC region stayed away from the vote, perhaps in protest after their candidate from Botswana failed to make any progress in the preliminary rounds.
SADC had argued they still deserved one more term because the current occupant from South Africa, Ms Nkosazana Dlamini-Zuma, had chosen not to run for a second term.