William Ruto built a career on beating the odds. In his greatest triumph, he is expected to be inaugurated as Kenya’s fifth president on Tuesday.NAIROBI, Kenya — William Ruto wept when he won, falling to his knees in prayer after Kenya’s Supreme Court confirmed his presidential win last week, the climax of a bruising courtroom battle over the results of a hard-fought election.Aides patted the sobbing Mr. Ruto, as his wife, a Christian preacher, and his running mate knelt by his side, thankful that a bid to overturn his win from the Aug. 9 vote had been thwarted.On Tuesday Mr. Ruto, who has been Kenya’s vice president since 2013, will be inaugurated as the country’s fifth president.The outburst contrasted with the image of a leader better known for his steel than for his tears. Since he began his political ascent three decades ago, enlisting as an enforcer for an autocratic president, Mr. Ruto has developed a reputation as a wily operator with a talent for reinvention and an instinct for ruthless pragmatism.He survived arduous shadow battles with his boss, President Uhuru Kenyatta. He won elections that he was widely predicted to lose. And he emerged as a free man from the International Criminal Court at The Hague, where Mr. Ruto had been charged with crimes against humanity, after witnesses changed their stories and the trial collapsed in 2016.“Ruto seems to thrive in going against the odds,” Macharia Munene, a political scientist at the United States International University in Nairobi, said. “Once he has garnered attention, he finds a way of separating himself, then comes out on top as a leader.”Supporters of Mr. Ruto celebrating in Nairobi on Monday.Ben Curtis/Associated PressThose qualities served Mr. Ruto especially well this past month. Not only did he vanquish his electoral rival, Raila Odinga, who had been favored to win by pollsters, but he also triumphed over Mr. Kenyatta, a former ally once so close to Mr. Ruto that they dressed in matching suits and ties.Mr. Kenyatta is now his embittered foe. After last week’s court decision, the departing president, who backed Mr. Odinga’s losing ticket, delivered a grievance-laced speech in which he refused to utter Mr. Ruto’s name, much less congratulate him on his win. It was the latest twist in a saga of loyalty and betrayal that has dominated Kenyan politics for over a decade.“I haven’t talked to him in months,” a chuckling Mr. Ruto told laughing supporters at his residence after the Supreme Court confirmed he would be replacing his former boss. “But shortly I will be putting a call to him so that we can have a conversation on the process of transition.”Already, Mr. Ruto has made soaring promises in eloquent speeches that his presidency will unlock the potential of Kenya, an East African economic powerhouse and regional anchor. But to Kenyans who look to his mixed record in office, blemished by violence and financial scandals, a Ruto presidency is a worrisome prospect.“He has so many unresolved controversies, which affects how much people are willing to trust and believe in him,” said George Kegoro, head of the Open Society Initiative for Eastern Africa, a democracy-promotion organization. “That’s a problem.”Few doubt his political skills. On the campaign trail, Mr. Ruto loved to tell of his humble origins: his barefoot childhood in the Rift Valley; his first pair of shoes at age 15; the early adult years when he sold chickens by the roadside to scrape by. That underdog narrative lay at the heart of his populist pitch to the “hustler nation” — young Kenyans striving to succeed on modest means, as he once did.It was also code for a kind of class warfare. Unlike other Kenyan leaders, educated at elite Western schools or ushered into politics by gilded bloodlines, Mr. Ruto grew up in a remote village where he raised cows and sang in the choir. In a freewheeling, alcohol-soaked political culture, he is a teetotaler who rises early, prizes punctuality and is unabashed about his Christian faith, attributing his successes to “the hand of God.”Employees in an electronics store watching the live broadcast of the Supreme Court of Kenya’s judgment on the general elections in Nairobi on Monday.Yasuyoshi Chiba/Agence France-Presse — Getty ImagesTo many ordinary Kenyans, that image resonated powerfully at a time of pandemic-induced hardship, said Mr. Munene, the analyst. “Everyone was suffering, yet the elite seemed to be doing fine,” he said.Many wealthy Kenyans, however, saw something different: “A thief and a murderer who is patently unsuitable to be president of this republic,” said Jerotich Seii, a one-time aid worker and Odinga voter, now a prominent Ruto supporter. “It’s a class thing.”Despite the slogan, Mr. Ruto was not the average “hustler.” He cut his teeth in politics in the early 1990s as a campaigner for Kenya’s longtime autocratic president, Daniel Arap Moi, a fellow ethnic Kalenjin. As minister for agriculture, then higher education, between 2008 and 2010, Mr. Ruto was seen an effective, hands-on leader, but no reformer: He sided with conservatives to oppose a new constitution that was approved in 2010.Along the way, he became very wealthy, growing a business empire that includes luxury hotels, a 15,000-acre ranch, a commercial farm and a huge poultry processing plant. He was implicated in corruption scandals, including accusations that he tried to grab land from a Nairobi school for a hotel parking lot — a case that is still before the courts.Mr. Ruto has always denied any wrongdoing — “I have been audited left, right, upside-down and inside-out” he said at a presidential debate in July — and many voters are willing to look past his wealth.“They are all crooks, we know that,” said Ms. Seii. “I’m going for the crook with a plan.”Mr. Ruto’s career has been shaped, to a large degree, by the International Criminal Court.In 2010 prosecutors accused Mr. Ruto and Mr. Kenyatta of leading the political violence that followed the disputed election of 2007 — the great trauma of recent Kenyan history, with over 1,200 people killed, and 600,000 others displaced, as the country threatened to tip into civil war.An opposition supporter being arrested in Kibera, a slum that is an opposition stronghold in Nairobi, in late 2007. Stephen Morrison/European Pressphoto AgencyThe I.C.C. indictment depicted Mr. Ruto as the godfather of mayhem in the Rift Valley, accusing him of distributing weapons, issuing kill-lists and telling supporters which houses to burn. But that case floundered badly at trial, ultimately managing only to unite Mr. Ruto and Mr. Kenyatta, and transforming Kenyan politics.The two leaders ran on a joint ticket in the 2013 election, with Mr. Kenyatta as president, portraying the court as a tool of Western oppression and rallying other African leaders to their cause.On the ground in Kenya, witnesses disappeared or changed their stories amid accusations of bribery and intimidation, and by 2016 the trials of both men had entirely collapsed.Mr. Ruto and Mr. Kenyatta became an apparently unstoppable force. Before they were re-elected in 2017, they finished each other’s sentences in interviews and joshed in a jokey campaign video, drawing comparisons with the Obama-Biden partnership in the United States.But a year later, it all fell apart. In 2018, Mr. Kenyatta signed a pact that switched his loyalties to Mr. Odinga, triggering a shadow war inside Kenya’s government.Uhuru Kenyatta, in a red shirt, as a presidential candidate, next to his running mate, Mr. Ruto, in a yellow shirt, at a rally in Nairobi in 2013. Now, they are bitter foes.Pete Muller for The New York TimesMr. Ruto started to build a political base in Mount Kenya, Mr. Kenyatta’s political backyard.Mr. Kenyatta used the state apparatus to thwart his deputy’s ambitions.Last year, a senior Kenyan government official made public a list of Mr. Ruto’s assets. Security agencies began to obstruct his movements. His supporters came under unusual scrutiny by the tax authorities, said a senior Western official who spoke anonymously to discuss sensitive issues.As the election drew near, the main news media outlets tilted their coverage in favor of Mr. Kenyatta’s ally, Mr. Odinga.And on Aug. 15, just before Mr. Ruto was declared the winner, a delegation of senior police, military and presidency officials tried to subvert his victory quietly, the head of the electoral commission, Wafula Chebukati, told the Supreme Court last week. The real test for Mr. Ruto may come when things aren’t going his way. He insists there’s nothing to worry about.“We are competitors, not enemies,” he assured his rivals after his victory was confirmed last week. “I pledge to make Kenya a country for everyone.”A poster of Mr. Ruto in Eldoret, Kenya, last month.Ed Ram/Getty ImagesAbdi Latif Dahir More