Obama warned that Kenya and other African nations will never thrive if their citizens cannot count on the government to deliver services fairly, regardless of their tribal background or ability to pay bribes, Obama told about 600 people at the state-run University of Nairobi.
"In the end, if the people cannot trust their government to do the job for which it exists — to protect them and to promote their common welfare — all else is lost," he said.
Obama is winding down his trip to Africa, which began Aug. 18 in South Africa. On Tuesday, he will visit the world-famous Masai Mara game reserve in southern Kenya, followed by trips to the countries of Djibouti and Chad.
The Illinois Democrat has received the warmest and largest welcome in Kenya, where Kenyans have claimed Obama as one of their own even though he was mostly raised in Hawaii and did not know his Kenyan father well.
This is Obama's third visit to Kenya but his first since being elected the United States' only black senator in 2004.
On Monday, he acknowledged the irony of a politician from Chicago, known for its long history of public corruption, talking about good government. But while corruption is universal, he said in Kenya it amounts to "a crisis that's robbing an honest people of opportunities they have fought for."
Government officials did not immediately respond to Obama's comments Monday. The senator had a closed-door meeting with President Mwai Kibaki last week.
Kenya has been roiled for years by widespread allegations of corruption. Kibaki won elections in 2002 promising to root out the corruption that had become endemic under the 24-year rule of his predecessor, President Daniel arap Moi. But now, he too is facing mounting pressure to respond to allegations of high-level corruption.
Kibaki's administration has pointed to its efforts to root out corrupt judges and ongoing investigations into high-level wrongdoing. Officials also have said that the government alone cannot fight corruption and asked individuals and companies to stop paying bribes.
Obama said Monday that the Kenyan government must reduce patronage jobs and increase salaries for the remaining employees to reduce temptation for taking bribes. It also needs clear laws and regulations, so that individual bureaucrats cannot twist the rules to their own ends, Obama said.
"Finally, ethnic-based tribal politics have to stop," he said to applause from the audience of students, university staff, business leaders and others.
Obama said his father, a Kenyan government economist, butted heads with government officials over ethnicity and patronage and ended up losing his government job. Obama said his father also held outdated views about the roles of women, and as a result never enjoyed a strong family life.
His father died in a car crash in 1982, leaving three wives, six sons and a daughter.
"In many ways, my family's history reflects some of the contradictions of Kenya and indeed the African continent as a whole," Obama said.
AIDS prevention also has been a theme of Obama's visit. On Saturday, he and his wife, Michelle, underwent public HIV tests at a hospital in the city of Kisumu in an effort to reduce the public stigma associated with HIV testing.
Obama and his family also traveled Saturday to Nyangoma-Kogelo, a tiny village in the rural west where his father grew up. Obama stopped at his father's grave and also visited his 85-year-old grandmother.