In 2007, a vote that was widely believed to have been flawed touched off spasms of violence that left at least 1,300 people dead and 600,000 displaced. Voting systems in 2013 were afflicted by widespread malfunctions that led to renewed accusations of vote-rigging, and more than 300 people were killed in postelection violence. Mr. Odinga has said he was robbed of victory because of vote-rigging in those last two contests.

So far, Mr. Odinga has not yet corroborated his claims that the results were hacked. But he said in the interview on Wednesday that he was “very confident” about the evidence, which he said had been provided by whistle-blowers working at the electoral commission. He has until this Friday to file a petition.

“This is a historic case, not just for Kenya but for Africa,” he said, and criticized observers for appearing to place more importance on preventing violence and instability over considering electoral fraud claims. “I believe the contrary to what observers say, that in Africa security is more important than democracy. African democracy must meet certain international standards.”

His decision to contest the results in court is a reversal from earlier statements, when he and his top aides had rejected calls to resolve electoral disputes in court, as they had tried to do after losing the 2013 election, saying they did not trust the judiciary’s independence.

In that race, Mr. Kenyatta won by a razor-thin margin, just enough to avoid a runoff, prompting Mr. Odinga to ask the Supreme Court to invalidate the election. At that time, the court challenge was hampered by the electoral commission’s failure to release all of the data from the polling stations.

“We had to go to court to get an injunction to get access to the data,” Mr. Odinga said. By the time the commission eventually came around to it, time had run out for the opposition to make its case.

This time, he said, the opposition is well prepared to challenge the results in court.

“The evidence is so clear,” Mr. Odinga said. “I’m very optimistic.”