NAIROBI, Kenya — President Mwai Kibaki was declared the winner Sunday of the closest presidential election in Kenya's history, a contest marked by allegations of rigging and two days of deadly violence.

Elections chief Samuel Kivuitu read the results on live television after other media were expelled from the main vote headquarters. Kibaki beat Raila Odinga by 231,728 votes.

"This means Honorable Mwai Kibaki is the winner," Kivuitu said.

Black smoke billowed from Nairobi's sprawling Kibera slum, where thousands of people have been on the streets for the past two days shouting "Kibaki must go!" and claiming the vote was rigged. Violence around the country has killed at least 15 people since Saturday, authorities said.

"These are our guns," said 24-year-old Cliff Owino, holding up a handful of rocks in Mathare, a Nairobi slum where young men were setting up roadblocks and building bonfires. "But a voting card is our atomic weapon."

Others were shouting "Kibaki must go!" and waving machetes in the air as buses and shops burned.

Odinga had called on Kibaki to concede and asked for a recount, saying the electoral commission "cannot possibly address the multiple levels of fraud administered by this administration."

But Kibaki's camp urged patience for the official results, and accused Odinga's Orange Democratic Movement of being behind the violence. "ODM is responsible for all the incitement that is taking place right now," said Danson Mungatana, an official with Kibaki's Party of National Unity.

The disputed campaign comes in one of the most developed countries in Africa, with a booming tourism industry and one of the continent's highest growth rates. Many observers saw the campaign as perhaps the greatest test yet of this young, multiparty democracy and raised grave concerns as the process descended into violence.

Alexander Graf Lambsdorff, chief European Union election monitor, said the Electoral Commission of Kenya "has not succeeded in establishing the credibility of the tallying process to the satisfaction of all parties and candidates."

Kivuitu, the electoral commission chairman, acknowledged problems, including a constituency where voter turnout added up to 115 percent and another where a candidate ran away with ballot papers.

Supporters of 76-year-old Kibaki say he has turned Kenya's moribund economy into an East African powerhouse, with an average growth rate of 5 percent.

He won by a landslide in 2002, ending 24 years in power by the notoriously corrupt Daniel arap Moi, who was constitutionally barred from extending his term.

But Kibaki's anti-graft campaign has largely been seen as a failure, and the country still struggles with tribalism and poverty. After the opposition took most of the parliamentary seats, he may find it difficult to rule even if he wins.

Odinga, a fiery 62-year-old former political prisoner, promised change and help for the poor. His main constituency is Kibera, home to at least 700,000 people who live in extreme poverty and the scene of many of Saturday's riots.

In recent months he has made it a priority to reach out to the country's middle class and businessmen, many of whom belong to Kibaki's tribe, the Kikuyu. Odinga belongs to the Luo tribe.

Associated Press writers Elizabeth A. Kennedy, Katharine Houreld, Malkhadir M. Muhumed and Tom Odula contributed to this report.