By Edmund Blair

NAIROBI (Reuters) - Kenyans choose a new president on Monday in a closely fought election that has divided the east African nation and raised fears of a repeat of the bloodshed that followed the tightly contested race five years ago.

Rival tribe members wielding machetes, knives, and bows and arrows butchered more than 1,200 people after the disputed 2007 vote, shattering Kenya's reputation as one of the continent's most stable democracies and dealing a heavy blow to east Africa's biggest economy from which it is only now recovering.

The government has spent five years trying to rebuild confidence with a reformed judiciary and newly appointed police commanders. Church preachers and civil society groups have brought politicians and rival voters together in rallies in Nairobi's central park to appeal for a peaceful vote.

Yet, this year's race is haunted by the past. One of the top two candidates, Uhuru Kenyatta, 51, has been indicted by the International Criminal Court (ICC) for instigating the violence after the 2007 race. And tribal loyalties will again largely determine who backs Kenyatta or his main rival Raila Odinga, 68.

The United States and other major Western donors are watching warily. Victory by an ICC suspect would make for tricky relations with a nation seen as vital to regional stability and a bulwark against militant Islam in neighboring Somalia.

Other neighboring countries fear another bout of violence will again choke the Kenyan trade corridor and send shockwaves through their economies. Landlocked Uganda has built up fuel reserves and its construction firms have stockpiled materials.

In Nairobi's Kibera slum, where a railway line was uprooted and shacks that were homes to thousands were torched after the last election, 32-year-old Esther Musemi said voters and politicians had learned the lesson and would accept the result.

"Last time, we were not aware but this time we know what is going on," she said. But she still put the chance of another flare-up at "fifty-fifty" and nearby store owners had depleted their stock to reduce potential losses if a new rampage erupts.

HIGH STAKES

Both top contenders are way ahead of the other six rivals, but polls suggest the race is too close to call, raising the prospect of a bruising run-off in April unless one candidate can get more than 50 percent. A narrow victory, however, could well be challenged by the loser or his backers.

Provisional results could emerge hours after the vote because of a new electronic tallying system, but official results may not be announced for a day or two, or even longer.

"Many people are saying they don't think Kenyans are going to be suckered into another round of clashes led by the political elite," said Africa Confidential editor Patrick Smith.

"But at the end of the day this is a bare-knuckle, brutal contest in which the stakes have rarely been higher," he said.

For Deputy Prime Minister Kenyatta, son of the first president after Kenya became independent from Britain in 1963, losing means he would have an unsympathetic government at home while he faces charges of crimes against humanity in The Hague.

Prime Minister Odinga, on the other hand, may be facing his last shot at the top job after narrowly missing out in 2007. Failure would mark another defeat in the family's political ambitions after Odinga's father fell out with Kenyatta's father in a long-running rivalry during the early years of Kenyan independence, and failed to secure the top post.

There are however differences this time that may reduce the prospects of widespread violence that had its epicenter in the Rift Valley, the agricultural heartland in the west of Kenya.

"Now you can hear all the key players saying that in the case of any disputes they will revert to the legal process for the resolution of that dispute," said Adams Oloo, head of political science at the University of Nairobi.

The new committee overseeing the vote has won support across the political divide. The judiciary has been reformed to free it from executive interference and has a new, widely respected chief justice, Willy Mutunga.

Investors are betting on a calm vote. Share prices have rallied and the shilling is trading around its strongest levels against the dollar this year.

'PEOPLE ARE WORRIED'

But worrying signs remain. Mutunga said this month he and other judges had received threats from a criminal gang that wanted to ensure no legal obstacles stopped Kenyatta running.

In Kibera, a shanty town where Odinga's Luo tribe loyalists live cheek-by-jowl with Kenyatta's Kikuyu, fears of a fresh flare-up are barely concealed.

"People are worried," said James Kamau, a Kenyatta supporter, as he sold some of the last planks of wood from a corrugated-iron shack, deliberately running down his stores. "At this time, I have no stock. It used to fill this whole place."

Signs of the violence in the slum are still visible. Some of the few cement block buildings in the area have never had their torched roofs repaired, and many residents have stories of homes or stores being demolished in the angry rampage.

Karen Adoyo, 36, wearing an orange Odinga supporter t-shirt, played down tensions but then warned of violence if Kenyatta was declared victor because "I know Raila is going to win."

To secure victory, both candidates have to reach out beyond their own ethnic groups. Kikuyu may be the biggest tribe but still only account for about a fifth of Kenyans. Odinga and Kenyatta both have picked running mates from other tribes.

The run-up has also been tense. Tribal violence fuelled by political rivalries killed almost 200 people late last year in the Tana region and scuffles marred primary races in the run-up to votes that will also include races for the governors of major cities and the upper and lower houses of parliament.

Leaflets have been distributed in some areas warning members of rival tribes to leave, a chilling reminder of the 2007 vote when about 350,000 people were forced to flee their homes.

Stephen Omondi, a maize seller in Kibera, said his friend in the port city of Mombasa had received one such threat and was leaving, while some residents of Kibera had packed up.

But the 42-year-old said he wouldn't leave the place where he was registered to cast his ballot. "I must vote. This is my country. This is my future and the future of all citizens."

(Writing by Edmund Blair; Editing by James Macharia and Giles Elgood)