The Kenyan Constitution requires there to be a general election on the second Tuesday in August in every fifth year.[2] There have been public discussions to move the date from August to December with proponents pointing to fiscal timeline (1 July – 30 June) clashing with an August date because most ministries that support critical election processes will not have been fully funded and that a possible presidential runoff vote may interfere with the national examinations calendar of October and December.[3] Opponents of the election date change have argued for protecting the constitutional provision and that any change would be mired by legal challenges and may drag on to the next elections and still require a referendum to decide, putting the country's stability at risk.[3]

On 7 August 2017, one day before the election, Barack Obama, who served as the 44th President of the United States from 2009 to 2017 and whose father was Kenyan, called for calm and acceptance of the election results.[4] The intervention was noted by the media as unprecedented.[4]

The President of Kenya is elected using a modified version of the two-round system: to win in the first round, a candidate must receive over 50% of the vote and 25% of the vote in at least 24 counties out of the 47 counties.[5][6]

The 337 members of the National Assembly are elected by two methods; 290 are elected in single-member constituencies by first-past-the-post voting. The remaining 47 are reserved for women, and are elected from single-member constituencies based on the 47 counties, also using the first-past-the-post system.[7] The 67 members of the Senate are elected by four methods; 47 are elected in single-member constituencies based on the counties by first-past-the-post voting. Parties are then assigned a share of 16 seats for women, two for youth and two for disabled people based on their seat share.[8]

The Independent Electoral and Boundaries Commission set the duration for political parties to conduct their primaries in April 2017 following the review of Kenya's Election Laws. Parties would have 14 days between 20 April and 2 May to conduct their primaries and submit their candidates to the electoral commission.[9]

On 29 July 2017, Deputy President William Ruto's house was attacked by a local man armed with a machete.[10] During the siege, the deputy president and his family were not present. The assailant first injured the guard on duty, held him hostage and then killed him. The siege lasted 18 hours before the Kenyan Police special forces shot the attacker dead. The motives of the attacker were unknown and members of the public were unaware how a man armed with a machete held the elite police forces for 18 hours.[11][12]

On 27 July 2017, two bodies were found on the outskirts of Nairobi. One of the dead, Christopher Msando, was the head of information, communication, and technology at the Independent Electoral and Boundaries Commission.[13] He played a major role in developing the new voting system for the election.[14] His body showed clear marks of torture before he was murdered for unclear reasons. Alongside it was the body of a 21-year-old woman, Maryanne Ngumbu.[15] The FBI and Scotland Yard offered to help in the investigation.[16]

Though Kenyatta and Odinga were virtually tied in opinion polls leading up to the election, the outcome was reported as a 10-percentage-point victory for Kenyatta.[17] On 10 August, provisional results released by the Kenyan electoral commission put Kenyatta ahead by 54.2% to Odinga's 44%. The head of the EU delegation Marietje Schaake said there had been no sign of manipulation of the result at central or local level and urged all sides to accept the result.[18]

Opposition leader Raila Odinga alleged that the results had been tampered with by hackers.[22] He offered no evidence to justify his claim, which the head of Kenya's electoral commission dismissed.[23] Following the election, there were protests in Kisumu, Kibera and Mathare where Mr. Odinga enjoys great political support , some of which turned violent and deadly.[22] Odinga published his own results, which put him ahead, and claimed that the commission's IT system had been hacked and that Kenya had seen the worst "voter theft" in its history.[24] The chairman of the electoral commission, Wafula Chebukati, responded that his organization was the only body allowed to count votes and that while there had been an attempt to hack the commission, it had failed.[24] A week after the vote, Odinga announced he would challenge the results in Kenya's Supreme Court.

The Economist did its own count of a sample of paper ballots, which tallied with the electronic results.[25]

Kenyatta's reaction incorporated invitations to several world leaders to his inauguration, including: former US President Barack Obama; German Chancellor Angela Merkel; British Prime Minister Theresa May; Italian Prime Minister Matteo Renzi; China President Xi Jinping; Liberian President Ellen Johnson Sirleaf; Nigeria President Muhammadu Buhar; Rwanda President Paul Kagame; Uganda President Yoweri Museveni; Tanzania President John Magufuli; South Africa President Jacob Zuma; His Royal Highness Aga Khan IV; and Nigerian billionaire tycoon Aliko Dangote.[26]

African Union: The AU mission led by Thabo Mbeki commended the Kenyan people on conducting the election in a peaceful environment. The AU acknowledged the dispute by the opposition, however, Mbeki refused to get involved in the investigation, citing the lack of mandate.[27]

Carter Center: The mission headed by John Kerry commended the Kenyan people in conducting the election peacefully. The Carter Center also commended the role of the judiciary throughout the entire electoral process.[28] Kerry urged that all disputes with the election be handled within the law.[29]

Commonwealth of Nations: The Chair of the Commonwealth Observer Group, former President of GhanaJohn Mahama, declared in the group's interim statement that the Kenyan elections across all six levels of government has been "credible, fair and inclusive". He appealed for continued patience as the results continue to be finalised. On allegations of fraud by the opposition leader, Mahama called for political leaders to show "restraint and magnanimity".[30]

It was announced on 13 August that the new Parliament would be sworn in on 22 August, with Kenyatta's second inauguration to follow a week later.[32] However, Kenyatta's inauguration was pushed back to at least September 12 after Odinga agreed to challenge the results in court.[33]