In his fifth, and possibly last, bid for president, Raila Odinga failed to enthuse a crucial bloc of voters in his own backyard that would have catapulted him to the top job.KISUMU, Kenya — For decades, Kenya’s veteran opposition politician Raila Odinga has been the chief political power broker in the western counties around Lake Victoria, relying on his fellow Luo ethnic voters to back him in five successive elections for president.They stuck with the man they affectionately call “Baba,” or “father,” as he challenged entrenched corruption and fell short of the presidency four times — twice in contested votes too close to call.But the loyalty of his Luo stronghold came into question last week, as Mr. Odinga, 77, was pronounced the loser of his fifth, and possibly last, bid for the presidency. In an election with over 14 million voters, the tally — which he said he plans to challenge in court — showed him only about 233,000 votes short of his rival, William Ruto, the current vice president.But he almost certainly would have clinched the prize if over 600,000 registered voters in four Luo-dominated counties had not failed to turn out. Many residents said in interviews that he had lost their support because he and his party endorsed wealthy party cronies and his own relatives — rather than young aspirants — for seats in governorship, Parliament and county assembly, suggesting that he had succumbed to the corrupt machine politics he had long opposed.“Raila was once the man of the people,” said John Okello, 38, a community organizer who lives in the low-income Obunga area in Kisumu, a city of 1.1 million that hugs the lake. “But that’s no more.”John Okello, a community leader in Obunga in Kisumu County, said he once considered Mr. Odinga a man of the people, but “no more.” Brian Otieno for The New York TimesEthnicity has shaped Kenyan politics for decades, leading to rampant corruption and disenfranchisement and, sometimes around elections, full-blown violence. But for the first time this year, millions of voters crossed ethnic lines, shifting the political dynamics in a nail-bitter election that ended with four of the seven national election commissioners walking out and declaring they could not stand by the final tally, only minutes before the head of the election commission pronounced the results.The ethnic shift was particularly evident in Central Kenya, where voters from the Kikuyu community — Kenya’s largest ethnic group — did not heed the guidance of President Uhuru Kenyatta, a fellow Kikuyu, who had anointed Mr. Odinga as his successor. Instead, voters in Central Kenya overwhelmingly cast their ballots for Mr. Ruto, an ethnic Kalenjin.“The presumption that many people have always made is that voters from one community will sway a certain way,” said Ken O. Opalo, a political scientist at Georgetown University, in Washington, who studies Kenya’s politics and traveled there during election season. “But there was both fatigue and dissatisfaction with Kenyatta’s performance, and William Ruto’s message resonated with many among the Kikuyu, which partly helped break the cycle of ethnic voting.”For Mr. Odinga, the failure to elicit excitement in his own region began before Election Day. During the primaries, his party, the Orange Democratic Movement, or O.D.M., installed party stalwarts as candidates, passing over up-and-comers.During the primary elections, when party members were voting, allegations of corruption, rigging and bullying marred the process, according to several party members, officials and candidates who vied for positions.Some of those who felt cheated decided to run as independent candidates, only to be pressured to withdraw. When they declined, they said they were ostracized, harassed and attacked.“We were accused of being anti-Baba or being the enemies of the party,” said Sospeter Obungu Owich, an ethnic Luo who said he ran as an independent candidate for a county assembly seat in Kisumu after party officials shunted him aside. He said he was attacked twice by “goons” while campaigning, and that two staff members were injured.Candidates like Sospeter Obungu Owich ran as independent candidates after they were pushed aside by Mr. Odinga’s party. Brian Otieno for The New York TimesPatrick Ayiecho Olweny, the chairman of Mr. Odinga’s party in Kisumu County, acknowledged the “harassment and the political violence” directed at Mr. Owich and others, and blamed it on “a generation of hostile youth” whom the party cannot control.He also admitted that the primary process had been fraught with political patronage and vote buying, but he blamed the party’s top brass in the capital, Nairobi, for mismanaging the whole process, saying, “It’s a total mess.”Nic Cheeseman, a professor of democracy at the University of Birmingham who has written extensively about politics in Kenya, said that for Mr. Odinga, “the claim to be a kind of pro-democratic opposition leader promoting change was undermined by not being able to organize his own party in a democratic way.”“Some of those disgruntled voters were less likely to come to the polls to vote for him as a presidential candidate,” said Mr. Cheeseman, who came to Nairobi to observe the election.By contrast, Mr. Ruto’s party, the United Democratic Alliance, managed its primaries better, with Mr. Ruto himself interceding to appease some disgruntled candidates, Mr. Cheeseman said.In the presidential election, turnout in the four Luo-dominated counties — Kisumu, Homa Bay, Siaya and Migori — was 72 percent — around 20 percent lower than the election in 2013. Turnout was also lower on the coast in Mombasa County, another major Odinga stronghold, where just 44 percent of voters turned out, compared to 66 percent in 2013.Mr. Ruto, 55, not only swept the Central Kenya vote — he even won at the president’s own polling station — but also managed to bring out almost 80 percent of voters in many counties in his stronghold in the Rift Valley. The four counties with the highest turnout in the August vote — Bomet, Kericho, West Pokot and Elgeyo Marakwet — all went to Mr. Ruto.Broken windows at a supermarket that was targeted during protests in Kisumu on the night Mr. Ruto was announced as president-elect. Protests have since subsided.Brian Otieno for The New York TimesBesides the bruising primary process and depressed turnout, Mr. Odinga’s campaign was also hobbled by a lack of clear messaging, experts say. Mr. Odinga had surprised his followers when in 2018 he made a pact with his long-term nemesis, President Kenyatta — an alliance famously known as “the handshake.” Critics labeled Mr. Odinga a “project” of the establishment, and he lost his claim to outsider status.In contrast, Mr. Ruto, a wealthy businessman and the country’s vice-president, cast himself as an ally of the country’s poorest, or what he called “hustler nation,” employing a wheelbarrow as his party’s symbol.Some of Mr. Odinga’s supporters lamented in interviews that after his alliance with President Kenyatta in 2018, Mr. Odinga did not return to his home base to engage young people on their concerns, including unemployment, or assist families that suffered from police brutality.After Mr. Odinga announced he would challenge the vote in court, initial protests in Kisumu quickly subsided and in the days since, many said in interviews that he should concede to Mr. Ruto and work with him.“Now that he’s lost the presidency, he should also get on the wheelbarrow movement and we move on together,” Alphonse Onyango, a 30-year-old security guard, said.The low-income Obunga area in Kisumu, part of Mr. Odinga’s stronghold.Brian Otieno for The New York Times More