What you need to know:
- On February 28, 2008, an internationally-brokered power-sharing agreement is signed under which Kibaki keeps his job and Odinga becomes prime minister.
In its 30 years of multi-party rule, Kenya's elections have frequently set off waves of deadly violence and produced contested results, with rival candidates accusing each other of fraud and vote-rigging.
As the East African country prepares for its next presidential and parliamentary election on Tuesday, we take a look at the past crises:
1992: First multi-party election turns deadly
Daniel arap Moi is elected president in Kenya's first multi-party poll on December 29, 1992, benefitting from deep divisions among opposition figures.
Moi had been in power since 1978 when he took over after the death of Jomo Kenyatta, Kenya's first leader after independence from Britain.
The 1992 vote is marred by violence between Moi's Kalenjin tribe and the Kikuyu tribe to which Kenyatta and much of the Kenyan elite belong. Hundreds of people are killed.
- 2007-2008: Post election violence
Outgoing president Mwai Kibaki is proclaimed winner for a second term on December 27, 2007 but his challenger Raila Odinga says the vote was rigged.
Clashes in the weeks that follow kill more than 1,100 people and force 600,000 from their homes in a country generally seen as a beacon of stability in Africa.
The epicentre of the violence is the Rift Valley, where members of the ethnic Kalenjin and Luo communities, who mainly back Odinga, clash with members of the Kikuyu community, to which Kibaki belongs.
On February 28, 2008, an internationally-brokered power-sharing agreement is signed under which Kibaki keeps his job and Odinga becomes prime minister.
In 2010, the International Criminal Court (ICC) opens a probe for crimes against humanity over the 2007-2008 violence.
Two years later its judges confirm charges against Uhuru Kenyatta, son of Jomo Kenyatta, and William Ruto, members of opposing parties at the time, for their alleged role in the violence
On March 4, 2013, Kenyatta wins the election and a year later he becomes the first sitting president to appear before the ICC.
But the cases against both Kenyatta and Ruto later collapse, with former ICC chief prosecutor Fatou Bensouda saying a relentless campaign of victim and witness intimidation made a trial impossible.
- 2017: Election annulled -
Kenyatta beats longtime rival Odinga in the August 2017 presidential election but Odinga rejects the results and claims hackers broke into the electoral commission database.
The announcement of Kenyatta's win sparks days of violent protests in Odinga strongholds.
Odinga takes his complaints to the Supreme Court and, in a shock announcement on September 1, judges declare the results of the poll "invalid, null and void" and order a re-run within 60 days.
The annulment is a first for Africa.
Kenyatta is re-elected in October in a vote boycotted by the opposition which is marked by low voter turnout.
Dozens of people die in protests that follow, mainly in clashes with police.
But the two men stun the country in 2018 by shaking hands and declaring a truce, leaving Deputy President Ruto out in the cold.