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.
"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, after being introduced by his sister Auma Obama to a crowd of 4,500, many of whom had secured tickets to attend.
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.
Bramwel Rotich, a 24-year-old student, said after the speech: "It was awesome. It was really inspiring especially for us young people."
After Kenya, Obama travels on Sunday 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 are 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.
National Security Adviser Susan Rice said last week the United States had concerns about Ethiopia's human rights record and the electoral process.