Over 1,100 people were killed and 600,000 fled their homes after the 2007 election. Kenyans hope for better this time

Displaced Kenyan people sit outside their makeshift shelters at Gilgil, near Naivasha. More than 100 families in this camp, chased from their homes in the violence that followed the 2007 polls, are still waiting to be re-homed. Photograph: Tony Karumba/AFP/Getty Images

"Welcome to Valley View photographic site," says the weathered wooden sign, boasting that you are 8,000 feet above east Africa's Rift Valley, the birthplace of mankind. A row of corrugated iron shops hawk traditional Masai cloths, soapstone chess sets and handcarved elephant, lion and zebra bookends. But today there are not many tourists to barter.

Down in the valley there's a clue as to why. Sunshine gleams off the metal roofs of housing built for families displaced by ethnic violence that followed Kenya's general election five years ago. More than 1,100 people were killed and 600,000 fled their homes. On Monday, the nation goes to the polls again in possibly the most important vote in its 50-year history. Many fear a repeat.

To outside eyes it is hard to believe that the most powerful country in the region, with its vibrant middle class, boutique malls and thriving tech sector, could be on the brink of catastrophe. But every five years, its foundations are shaken by the democratic cycle. Already in recent months more than 200 people have been killed in politically charged violence in the Tana river region and in the north. The fact that one of the front runners for the presidency has been indicted by the international criminal court is another portent of trouble ahead.

The Rift Valley in particular has become accustomed to these convulsions. Internally displaced persons (IDPs) are still living with the consequences of the politically fuelled tribal conflict in 2007-08.

Margaret Wambui Mwai, 65, is 280km from her home village and mourning her son, Joshua, who was hacked to death in the post-election eruption. "I last saw him the day before he died," she recalls, halting as her eyes cloud with tears. "He said 'Goodnight, I'm going to bed, you won't see me in the morning.' He was a carpenter so he spent the whole day at the workshop. He was supporting the whole family.

"The next time I saw him he was lying dead. He had been hacked to death on his way back from work. The memory still haunts me. The doctors at the mortuary could not salvage the situation so he was buried with his head almost off."

Margaret Mwai outside her house in Maai Mahiu in Naivasha. Photograph: Steve John Steve John/Steve John

Joshua, 42, left behind three wives and 12 children. The explosion of violence caused Mwai to flee for her life. "People started burning houses. We ran away, we didn't salvage anything, we left our things to burn. It was a very frightening time. We had to run in the middle of the night. We could only carry the very young; boys of 10 had to run for themselves, then we had to look for them the next day."

The widow, whose arms are deeply wrinkled and coated in dust, now lives alone in a spartan grey brick house with floors and walls that are bare save for a garish colour image of Christ. Does she fear another lethal election? "I'm highly religious, I believe in God. I think we will not fight again."

An informal settlement of some 6,000 families has sprung up in the Maai Mahiu area beneath majestic green hills, according to the local chief. But not all are officially recognised as IDPs and entitled to benefits. For Mary Nseri, 35, a single mother of six children, life is much tougher than it was five years ago, when she fled her burning home.

"It's very difficult to earn a living here," she says, standing beside a tiny home improvised from mud, branches and polythene liners, her modest kitchen having collapsed in the wind. "There is nothing to do. It's so dry that nothing is growing.

"Life was much better in my old village even if you didn't have a job. There was more rain so you could always find work on a farm. You never went hungry. The way we eat here is sporadic: sometimes we don't have breakfast."

Nseri cannot afford the 900 shillings (£6.90) for her daughter's exams at the end of primary school. Two other daughters have been forced to drop out of school because of fees. Election time still fills her with dread.

"We are really afraid," she adds. "We don't know what could happen. We will vote but we are worried the same thing could happen again. It's a precarious situation. Some people living in the interior are moving out to where they feel safe. We're not sure. Anything could happen."

Nearby, in baseball cap and torn shirt, is David Kamau, who life has been turned upside down by election violence for 20 years. Whereas he used to own eight acres of land, now he has only one eighth of an acre. "It's a hard life," he muses. "When the sun shines we have snakes getting into the tents. When it rains, the tents are washed away. The wind tears open the roofing."

Mwai, Nseri and Kamau are all ethnic Kikuyu - and all intend to vote for Uhuru Kenyatta, a Kikuyu running for president. They credit him with saving them from ethnic Kalenjin militias last time. Land ownership has been a longstanding grudge between the Kikuyu and Kalenjin communities. For this election, Kenyatta has formed a pact with William Ruto, a prominent Kalenjin, raising hopes of peace in the Rift Valley at least.

Victory for the wealthy, smooth-talking deputy prime minister would make him the second president in Africa to be indicted by the ICC after Sudan's Omar al-Bashir. It is feared that Kenya will go from cosy western ally to sanctioned pariah state. Kenyatta's principal rival, Raila Odinga, observed dryly that it would not be possible for him to run a "government by Skype" while he stands trial in the Hague.

The two men are refighting their fathers' old battles. Jomo Kenyatta was Kenya's first president while Jaramogi Oginga Odinga, an ethnic Luo, was vice-president until their relationship soured. This year promises another chapter in the rift between Kikuyus and Luos, for example in Mathare, a slum in the capital, Nairobi.

Not all Kenyans, however, believe they are prisoners of tribalism condemned to repeat the past. Ngunjiri Wambugu is convenor of Kikuyus for Change and a political adviser to Odinga, not Kenyatta. He says members of the group are working for various candidates cutting across tribal lines. "If you are Kikuyu you would not automatically be a supporter of Uhuru Kenyatta," he says.

"This is a turnkey election. We have two forces at play: a past based on tribalism and a future that is about issues and ideas. Our generation of young middle class people are speaking across politics, which was not happening in 2007. By the next election ethnic identity will be a lot less important. There is a new generation of leaders and many of us do not have that tribal ideology."

There are other grounds for optimism after years of introspection. Kenya has a new constitution and a stronger electoral commission and judicial system with a widely admired chief justice. Civil society groups have promoted non-violence and moved to clamp down on hate speech in social media. The outside world is paying unprecedented attention, pouring in more than $100m (£66m), and the ICC could now be a deterrent. The candidates held a joint prayer rally and are preaching peace, in public at least.

One initiative by Unicef, the UN children's agency, after the last election has led to the formation of a professional football club. Training at Nairobi School, defender John Kiarie, 17, who witnessed people being killed with axes and machetes in his home village, says: "The team was started from different areas and different tribes. Tribalism is not an issue. We love each other. We are like brothers here."

But if, as predicted, the contest is so close that Odinga and Kenyatta are forced into a run-off next month, sparks may fly in the ethnic tinderbox.

"We can't remove the fact that the politics of this country were based on ethnic foundations," says George Morara, senior programme officer at the Human Rights Commission. "The districts were zoned around ethnicities. People learned to associate their ethnic identity with political representation.

"You can't move away from that thinking. You grow up in your small ethnic bantustan and think the other people are wild animals you should not meet or interact with. People vividly see that you have to be in power to participate."

A well-educated nation where the middle class can take cookery classes or eat at Italian delicatessens, and where the likes of Google and Nokia are part of an African "silicon valley", could be about to discover how thin the veneer of affluence really is. The economy took a big hit from the mayhem last time, with growth dropping from 7.1% in 2007 to 1.6% the following year.

Sitting in an upmarket restaurant decorated by African art, Ndungi Githuku, 40, a human rights activist and artist, reflects: "Kenya is a strange place. It is beautiful in a very bitter way. The contradictions are very hard to explain. Kenya does not give you any warning signs of what you're going to see next. When you're driving in the leafy areas it's orderly, then suddenly you're in a sprawling ghetto. It's like being blindfolded then suddenly you're in a completely different place.

"The majority of people working here will return to the slums where there's no water or electricity this evening. You come and cook good food at a restaurant for 5,000 shillings [£39] a plate but your single room home is 5,000 shillings a month and your salary is threadbare."

He adds: "The most disgusting thing to me is that we are the ones who vote the same people back. Can we not think otherwise? We go with the devil we know. Then when blood is spilled, it happens in the slums. In the leafy suburbs, life goes on."