The connection between President Obama and Kenya has always been an echo of his relationship with his Kenyan father, which he once described as “an abstraction.”

On Sunday, Obama sought to make that connection real as he laid out a detailed case about what he thinks needs to change for Kenya to become one of the globe’s emerging powers.

Speaking to a crowd of 4,500 in the Safaricom Indoor Arena, Obama spoke of how he had “a sense of being recognized, being seen” during his first visit to Kenya three decades ago, how his last name no longer seemed strange.

Noting that Kenyans have the phrase “home anywhere you go,” Obama added, “That’s the Kenya that welcomed me nearly 30 years ago.”

But the heart of the speech was more lecture than reminiscence, as he used his standing as a beloved son of Kenya to critique a country still fraught with tribalism, sexism and corruption. Under different circumstances, or delivered by someone else, the speech could have sounded like intrusive moralizing by a foreign president. To Kenyans, particularly those dissatisfied with their government, it sounded like sage advice.

“A magical lecture,” declared Kenya’s Standard newspaper.

“If it came from another world leader, it might be different,” said Augustus Muluvi, head of foreign policy at the Kenya Institute for Public Policy Research and Analysis. “But this is coming from someone who knows Kenya, someone who has family here.”

Obama praised Kenya’s considerable economic and political progress in recent decades. But he said that to fully prosper, it needed to root out corruption, end discrimination against women and girls, and show tolerance for minorities even as it pursued an intense war against terrorism.

“You can’t be complacent and accept the world just as it is,” the president said. “You have to imagine what the world might be and then push and work toward that future.”

Although he emphasized that nations around the globe have different cultures, he also said there was no excuse for practices such as genital mutilation, the sexual and physical abuse of women, or the denial of educational opportunities for girls.

“Those are traditions, treating women and girls as second-class citizens. Those are bad traditions,” he said. “They need to change. They’re holding you back.”

Obama made a specific appeal to young Kenyans, saying they were “not weighed” down by those old traditions.

President Obama showed off his dance moves to the music of Kenyan pop group Sauti Sol during a state banquet in Nairobi. (Sauti Sol/Instagram)

“You are poised to play a bigger role in this world, as the shadows of the past are replaced by the light that you offer to an increasingly interconnected world,” Obama said. “So now is time for us to do the hard work of living up to that inheritance.”

The crowd, including many young students, cheered throughout Obama’s speech, taking photos with their smartphones and iPads or waving American and Kenyan flags.

Across Nairobi, residents gathered in homes, restaurants and other meeting places to watch the televised address. In Kibera, the city’s largest slum, some draped American flags from their homes and stores. In downtown Nairobi, five young men dressed their friend as Obama and pulled him through the streets in a cart.

At the Chicken Inn in downtown Nairobi, people watched on a television as Obama greeted the audience in Swahili.

“I wonder what he’s been eating here,” one woman said.

“Why didn’t he bring Michelle?” another asked, referring to the first lady.

“I wish I could be in the stadium with him,” a young man said.

After years of waiting, many here were eager to gauge Obama’s commitment to Kenya. Would he treat the visit as just another stop on a global tour? Would he speak to them as a world leader or as a man with roots in Kenya?

“When you see him, you can see the bonding,” said Charles Samperu, a humanitarian worker from Kajiado, south of Nairobi. “He is not someone who would deny his family.”

Enthusiasm for Obama’s visit was evident along the parade route from Kenyatta University to the speech site, where thousands stood roadside to watch the motorcade pass. Although many of the students on campus cheered unabashedly, most of the Kenyans along the major thoroughfares and in an informal settlement in the community of Thika — just outside Nairobi — stood transfixed. One woman stood by a wheelbarrow filled with sacks; others watched from balconies, staring at the spectacle of the armored presidential limousine and its trailing entourage.

Obama did not speak at great length about his father, Barack Hussein Obama, except to say that, as a sign of progress, Kenyans no longer needed to leave their country — unlike his father — to seek higher education.

That was one of the moments when some listeners thought Obama was speaking about a Kenya they didn’t recognize.

“That’s just not true,” said Jacktone Juma, a customs agent on vacation from his job on the Ugandan border, watching the speech in a Nairobi restaurant. “If you want to make decent money, you still need to go overseas.”

Obama has built a close relationship with Alma Obama, a daughter from his father’s first marriage, but his father’s tangential role in his upbringing complicates matters for the president in relation to Kenya.

Former White House senior adviser David Axelrod noted that when it comes to Obama’s Kenyan family, “the chief connection” is “a father he didn’t know. That, by definition, makes it complicated.”

Still, Obama has emphasized his Kenyan roots throughout his visit, saying Sunday that he was proud to visit the country not just as the first sitting U.S. president to do so but as “the first Kenyan American president of the United States.” It is hard to imagine that he would have uttered such a phrase during his first term.

In Washington, Obama’s Kenya connections are a punch line, to such an extent that even the president joked about it Saturday night.

“I suspect that some of my critics back home are suggesting that I’m back here to look for my birth certificate,” he said at the state dinner in Nairobi, prompting laughter and applause from the audience. “That is not the case.”

Here, Obama is a symbol of possibility. “What President Barack Obama has given back to us is a belief and a hope that, empowered, we can do and achieve for ourselves,” Kenyan President Uhuru Kenyatta said in his toast Saturday. “He has given us the tools and the belief that it is possible, through our own initiative and hard work, that we can take control of our own destiny and that we can lead change not just on our continent but in the world.”

During his previous trip here, as a senator in 2006, he arrived with “a skeleton crew,” recalled Mark Lippert, who worked for Obama at the time and now serves as the U.S. ambassador to South Korea. Although that journey had a helter-skelter feel at times — the bus that carried several aides to his family’s village in Kisumu nearly ran out of gas, forcing it to peel off from the motorcade as press secretary Robert Gibbs paid to refuel — it also gave Obama more of a chance to interact with ordinary Kenyans.

When Obama took a public HIV test in Kisumu, villagers perched in trees to watch.

Kenyans from his father’s native village of Kogelo still remember that visit clearly. While Obama was there, the village’s two schools were named after him. A decade later, people still talk about where they were when they shook his hand or how badly they regret not shaking it.

On this visit, though, the president spent time explaining to close relatives and ordinary citizens why the constraints of his office have held him back from spending more time in Kenya.

“Part of the challenge that I’ve had during the course of my presidency is that, given the demands of the job and the bubble, I can’t come here and just go upcountry and visit for a week and meet everybody,” he said Saturday, recounting how he apologized over dinner with three dozen of his Kenyan relatives shortly after his arrival in Nairobi.

Pledging to do philanthropic work here after his presidency, he noted, “I’m more restricted, ironically, as president of the United States than I will be as a private citizen in terms of some of the hands-on and direct help that I’d like to give.”

“Well, here’s what I can guarantee,” he added. “I’ll be back. The next time I’m back, I may not be wearing a suit.”