U.S. President Barack Obama told Kenyans on Sunday on his first presidential trip to his father's homeland there was "no limit to what you can achieve" but said they had to deepen democracy, tackle corruption and end exclusion based on gender or ethnicity.
After political talks on Saturday with President Uhuru Kenyatta on security and business, his speech to a packed sports hall in Nairobi struck a personal note, talking of his own experience and Kenya's in the five decades since independence.
Kenya was the first leg of a trip to Africa. Later on Sunday, he arrived in neighboring Ethiopia, one of the continent's fastest-growing economies and headquarters for the 54-nation African Union.
"I'm here as president of a country that sees Kenya as an important partner. I'm here as a friend who wants Kenya to succeed," he said in the Nairobi arena, after being introduced by his sister Auma Obama to a crowd of 4,500 people.
To a mixture of applause and laughter, he described being picked up at the airport on his first visit to Kenya in the 1980s by his sister in an old VW Beetle that often broke down. This time, he arrived on Air Force One and traveled in the president's armored car nicknamed "the Beast."
"When it comes to the people of Kenya, particularly the youth, I believe there is no limit to what you can achieve," he said, but he told Kenyans that building their nation and the economy required personal effort and responsibility.
On corruption, an issue often blamed for holding back investment, Obama said money spent on bribes would be better paid to someone "doing an honest day's work".
Referring to ethnic fighting in which 1,200 people died after a disputed 2007 election, he told Kenyans that politics based on ethnicity was "doomed to tear a country apart."
He also warned Kenya would "not succeed if it treats women and girls as second-class citizens."
Obama spoke of Kenya's challenge in dealing with attacks by the Somali Islamist militant group al Shabaab, and promised the United States would stand by Kenya as a "partner". On Saturday, he offered extra counter-terrorism training and funds.
Kenya's tourist industry has been hammered by attacks by al Shabaab, who raided a Nairobi shopping mall in 2013 and attacked a university in the northeast in April. Hundreds were killed in those and other attacks.
Obama, whose father is buried in western Kenya, wants to boost business ties with Africa, one of the world's fastest growing regions. "Kenya is on the move, Africa is on the move," he told the crowd at the sports hall.
"It was awesome," Bramwel Rotich, a 24-year-old student, said after the speech. "It was really inspiring, especially for us young people."
Following his speech, Obama met civil society groups who tackled issues that ranged from animal poaching to women's rights to Islamic radicalism. He also spoke to a local radio station, at one point describing favorite tour sites in Kenya.
He then continued on to Ethiopia, a nation brought to its knees by famine in the 1980s that now boasts some of the fastest economic growth rates on the continent.
But rights groups say economic achievements have come at the expense of political freedoms. The opposition failed to secure a single seat in a parliamentary vote in May. The government says opponents are free to speak their minds.