* Odinga says to challenge election result in court
* Began life as a socialist but built a business portfolio
* Learned hard lessons during years in jail
By James Macharia
NAIROBI, March 9 (Reuters) - Defeated presidential candidate Raila Odinga sought to tap into the Kenyan public's thirst for transparent government but has failed again to shake off a reputation as an also-ran that goes back to the time of his father.
Uhuru Kenyatta, indicted for crimes against humanity, was declared winner of the poll with 50.07 percent of the votes, just enough to win avoid a run-off, but with a commanding lead over Odinga's 43.31 percent.
Famed for regaling crowds with local folklore and jokes, the man who was once a socialist and now calls himself a social democrat narrowly lost the 2007 vote to President Mwai Kibaki.
Although Odinga opposes tribal politics, he has again failed to deliver a presidency to his Luo people in a nation where tribal loyalties often trump ideology.
He said he would challenge the outcome in court but has asked supporters to avoid violence after the wave of tribal bloodletting that followed the 2007 election.
"I always say that tribalism is a disease of the elite," he told Reuters in an interview at his home before the vote. "They are the ones who in competition for the resources of the country invoke ethnicity as a tool against each other."
Two of three presidents since independence from Britain in 1963 have been Kikuyu, and the Luo - the fourth-biggest tribe - complain about being left out of power since a feud between Odinga's father, Jaramogi Oginga Odinga, and Jomo Kenyatta, father of Uhuru and Kenya's first prime minister and president.
With Saturday's result, Odinga fell short of his aim to redress the disappointment of his father, who was at the heart of Kenyan politics in the early years of independence but also never secured the top job.
Odinga helped the now-outgoing president Kibaki win power in 2002. Three years later Odinga campaigned against Kibaki in a constitutional referendum and was sacked from government.
When Kibaki won a second term in 2007, he beat Odinga, who said the vote was rigged, plunging Kenya into weeks of deadly tribal violence. Under a power-sharing deal brokered to end the nationwide massacres, he was given the prime minister's post.
In this year's race, he championed the cause of the poor but had to fend off questions about how he acquired his family businesses, though far smaller than Kenyatta's.
"Can you let a hyena guard your goats?" Odinga asked supporters in rallies across Kenya, taking a swipe at the vast tracts of land held by Kenyatta and his family and punching holes in his opponents promise to resettle landless Kenyans.
Kenyatta is listed as Kenya's richest many by Forbes.
Representing Nairobi's Kibera slum, one of Africa's largest, Odinga projects himself as a friend of the poor, but critics say he has done little to fight poverty in the shanty town, a vast cluster of roughly made corrugated-iron and mud shacks.
His ethnically aligned supporters have seemed ready to forgive him this, and his supporters are many in the slum.
Like his father, Odinga, started as a socialist, his leanings reinforced during time spent studying engineering in communist East Germany. He even named his son Fidel after Cuba's former leader Castro.
Odinga, a 68-year-old loyal supporter of England's Arsenal soccer team, now pitches himself as a reformer, but his early socialist reputation still follows him.
Many among Odinga's loyalists had hoped he would win the presidency, expecting him to redress decades of tribal imbalances in a country where political support and patronage is largely drawn along ethnic lines.
But big business was more wary. "They think he still harbours some recherché dirigiste, East European, socialist ideas, despite having his own vast business interest these days," said Africa Confidential editor Patrick Smith.
Known by many as "Agwambo" or the controversial one, and "Jakom" or the head, Odinga has at times cut the image of a firebrand. In a biography, he indicated he was a plotter in an attempted coup against then president Daniel arap Moi in 1982.
For several years Odinga was detained and tortured at the hands of agents of Daniel arap Moi, who as president for 24 years until 2002 had kept an iron grip on the nation's politics.
"My impression is that life has taught him some hard lessons and by the time he emerged from nearly a decade of imprisonment, without trial, and torture at the hands of the Moi regime, he had pretty much turned his back on ideology," said the Atlantic Council's J. Peter Pham who spent a long weekend with Odinga in late 2011 discussing how to jumpstart economic growth.
A man who says he enjoys family breakfasts at his villa with its lush garden in the well-to-do Karen suburb of Nairobi, Odinga has built up family businesses and cultivated close ties with the financiers and entrepreneurs driving growth, Pham said.
Often seen in a Texas-cowboy Stetson at local soccer games, he promised to battle entrenched corruption. But, like other candidates, he faced scrutiny over his own business dealings, though not embroiled in Kenya's big corruption scandals.
In a presidential debate, Odinga was grilled on his family's stake in a molasses plant. He said it was legally bought.
With the campaign slogan "tuko tayari" or "we are ready", Odinga had promised to steer Kenya into a new democratic era where the last vestiges of autocracy still left in the hands of the presidency would be replaced. He hasn't quite made it. (Editing by Edmund Blair and Alison Williams)