Kenya's Supreme Court this week completed two days of hearings during which the opposition alleged fraud it claims handed victory to President Uhuru Kenyatta in the August 8 poll.
On Friday the court's seven judges will rule on whether the election should be annulled and rerun, as the opposition National Super Alliance (NASA) demanded, or the vote and result should stand, as the election commission and Kenyatta contended.
The country is on tenterhooks as it awaits the result, here's why.
Election day was calm with more than 15.5 million Kenyans voting for president, governors, senators, parliamentarians, local assembly members and women's representatives.
The overwhelming majority of international observers welcomed the successful holding of the elections.
The presidential election -- preceded by an acrimonious campaign and the murder of the IT manager at the Independent Electoral and Boundaries Commission (IEBC) -- pitted incumbent President Kenyatta against Raila Odinga, who had run unsuccessfully three times in the past.
As initial votes were being counted in the early hours of August 9 the opposition cried foul, alleging hacking and rigging were resulting in a false tally favouring Kenyatta.
The August 11 declaration of Kenyatta's victory with 54.27 percent of the votes, against 44.74 percent for Odinga, was followed by two days of demonstrations and riots in the slums of Nairobi and in the western city of Kisumu, traditional opposition strongholds.
At least 21 people, including a baby and a nine-year-old girl, were killed on 11 and 12 August, mostly by police, according to an AFP tally.
The violence, however, has fallen far short of the politically-motivated ethnic violence that left more than 1,100 dead following the disputed 2007 election.
What does the opposition want?
After initially ruling out taking its complaints to court, the opposition in the end asked the Supreme Court to annul the result of the presidential election, filing its petition just hours before the constitutional deadline on August 18.
Opposition lawyers denounced a "litany" of irregularities, accusing the IEBC of having falsified results during the several days it took to publish polling station and constituency tally sheets on its website.
The Supreme Court ordered the opposition lawyers be granted access to IEBC computer servers, documentation, voter identification kits and GPS data. The IEBC failed to abide by all the orders of the court yet opposition lawyer James Orengo claimed the information gathered proved the fraud allegations affecting more than five million votes.
The IEBC denied rigging but acknowledged some "inadvertent errors" that it said would not affect the outcome of the vote.
On Friday the Supreme Court will either validate the election and Kenyatta will be sworn-in a week later for a second five-year term or it will annul the presidential election giving the IEBC 60 days in which to organise a fresh vote.
The response of the losing party -- at the court as at the ballot -- and its supporters will be key to Kenya's short-term stability.
In that respect much will depend on the perceived quality and impartiality of the judges' ruling, which is final and cannot be appealed.
In 2013, the then Supreme Court judges were widely criticised for their rejection of Odinga's case, again alleging fraud.
Murithi Mutiga of the International Crisis Group think tank said the current procedure has been impressive so far with sessions broadcast live on television and with opposing lawyers laying out their arguments with courtesy and clarity.
But, he warned, "even if the quality of the ruling is high, some people will be disappointed" and that can spell trouble in a country where elections routinely put pressure on ethnic and economic fault lines.