Kenya election
Supporters of deputy prime minister Uhuru Kenyatta rally in Suswa, in the Rift Valley

Thousands of Kenyans gathered in Nairobi for rival rallies by the two presidential front-runners, two days ahead of the first polls since more than 1,000 people died in the bitter post-election violence of 2007.

Prime Minister Raila Odinga accused the electoral commission of giving his rival deputy prime minister Uhuru Kenyatta the advantage by "design or omission".

The president has urged Kenyans to vote peacefully on Monday 4 March, and for the losers to accept defeat, but his comments hint at legal wrangles and tension if the result is as close as analysts predict.

Kenyatta is facing trial at the International Criminal Court in The Hague in a few weeks over allegations he orchestrated some of the bloodshed in 2007. He denies the charges.

More than 1,200 people died and an estimated 600,000 were forced from their homes in ethnic violence in 2007 after Odinga disputed the victory of incumbent president Mwai Kibaki, claiming he had been cheated by Kibaki supporters. Odinga later joined a government of national unity under a peace deal.

Odinga said he was still confident of a first-round victory in the election, which will be the first held under the new constitution, which was adopted in 2010 in an attempt to avert further ethnic clashes.

Speaking on the last day of campaigning, Odinga said the election committee had failed to register all voters in his core constituencies, but not in Kenyatta's heartlands. But unlike in 2007, he said he had confidence in a reformed judiciary to adjudicate.

If he sought to raise a challenge, Odinga said, "We will go to court and we will urge our people to be calm and peaceful and await the outcome of the petition."

Odinga said the election commission had failed to send enough biometric registration kits to strongholds of his Coalition for Reform and Democracy, so that his supporters were under-represented on voter lists.

"Rigging of an election is not just on the polling date," Odinga said. "I don't know whether it is by design or by omission."

Addressing crowds of supporters, Odinga reaffirmed his undertaking to accept the outcome of Monday's vote.

"In the unlikely event that we are defeated we will accept the result. Any anomalies will be pursued through the courts," he said, urging his supporters to "be peaceful because we are winning".

Kenyatta held his final rally at Uhuru park, around a mile north of Odinga's main campaign event at the Nyayo national stadium.

Former vice president Wycliffe Musalia Mudavadi, who is currently polling in third place, was holding rallies in western Kenya, according to reports.

The events of 2007-8 continue to haunt the nation. The Kenya National Commission on Human Rights this week released a report detailing cases of violence, hate speech and ethnic intimidation, and warning that the candidates had "continued to raise emotions and inflame passions as they campaign for votes".

On Saturday 2 March, Odinga denied a report in the Financial Times that quoted him as saying that "blackmail and intimidation" would be to blame if he lost. He called the story a "total fabrication" and said he felt "absolutely slandered".

In a televised address to the nation on Friday, President Kibaki called on the electorate to "cast your vote and keep the peace", adding: "Let us send a clear message to the world that our democracy has come of age. A peaceful vote is a vote for a secure, prosperous and stable Kenya."

The government has deployed almost 100,000 police officers at polling stations around the country in an effort to prevent a repeat of the violence.

Tribal loyalties typically trump ideology for many voters. But Odinga, from the Luo tribe, and Kenyatta, a Kikuyu, will need to reach beyond their tribal heartlands if they are to win with more than 50 percent of the vote. Both have picked running mates from other ethnic backgrounds.

Western donors and investors will play close attention to the outcome for East Africa's biggest economy, a country that was for years seen as one of the continent's most stable democracies.