NAIROBI, Kenya — President Barack Obama mixed blunt messages to Kenya's leaders on gay rights, corruption and counterterrorism Saturday with warm reflections on his family ties to a nation that considers him a local son.
He foreshadowed a focus on Kenya in his post-White House life, saying, "I'll be back."
Obama's comments during a news conference with Kenyan President Uhuru Kenyatta reflected the unusual nature of his long-awaited visit to this East African nation. His official agenda has been sprinkled with opportunities to reconnect with his late father's sprawling Kenyan family, including some meeting the American president for the first time.
"There are cousins and uncles and aunties that show up that you didn't know existed, but you're always happy to meet," Obama said. "There were lengthy explanations in some cases of the connections."
Obama did little to paper over policy differences with Kenya's government, most notably on gay rights. He drew on his own background as an African-American, noting the slavery and segregation of the U.S. past and saying he is "painfully aware of the history when people are treated differently under the law."
"That's the path whereby freedoms begin to erode and bad things happen," Obama said. "When a government gets in the habit of treating people differently, those habits can spread."
Kenyatta was unmoved, saying gay rights "is not really an issue on the foremost mind of Kenyans. And that is a fact."
A number of Kenyan politicians and religious leaders had warned Obama that any overtures on gay rights would not be welcomed in Kenya, where gay sex is punishable by up to 14 years in prison. The Kenyan gay community also complains of sometimes violent harassment.
Obama also pushed Kenya to tighten its counterterrorism practices, which human rights group say have resulted in serious abuses. A Human Rights Watch report this year accused the Kenyan government of "extrajudicial killings, arbitrary detentions and torture by security forces."
"If in reaction to terrorism, you're restricting legitimate organizations, reducing the scope of peaceful organization, then that can have the inadvertent effect of increasing the pool of recruits for terrorism," Obama said.
Kenyatta called the scourge of terrorism "an existential fight for us." The Somalia-based al-Shabab, which is linked to al-Qaida, has conducted major attacks in Kenya, including the 2013 attack on Nairobi's Westgate mall and an April attack in Garissa that killed nearly 150 people.
Obama also urged Kenyatta to keep up efforts to combat corruption, calling that the biggest potential threat to Kenya's economic growth. But he said fulfilling anti-corruption pledges will require "visible prosecutions," and had told Kenyatta, "People aren't stupid."
Obama's trip to Kenya was the first to his father's homeland since winning the White House, as well as the first visit by a sitting American president. Despite intense security throughout Nairobi, crowds gathered to watch Obama's motorcade speed through the city. U.S. and American flags lined the main road from the airport and billboard's heralded his arrival.
Acknowledging that some Kenyans have been frustrated that it took him until the seventh year of his presidency to visit, Obama joked that he did not want the rest of Africa to think he was "playing favorites." He will also visit Ethiopia on this trip.
Obama's election in 2008 was cheered in Africa, not just because of his family ties, but also because there was an expectation he would devote significant attention to the continent. Those high hopes have been met with some disappointment, given that Obama's foreign policy has focused heavily on boosting ties with Asia and dealing with conflict in the Middle East.
The White House rejects that criticism, noting that Obama is making his fourth trip to Africa, more than any previous president. Officials are particularly sensitive to criticism that Obama's Africa policies pale in comparison to his predecessor, George W. Bush, who launched a multibillion-dollar HIV/AIDS program.
On Saturday, Obama said many of his African initiatives, including a program to vastly increase access to power, were intended to be yearslong efforts. He also credited Bush's health programs with saving millions of lives.
"I am really proud of the work that previous administrations did here in Africa, and I've done everything I could to build on those successes," he said. "This isn't a beauty contest between presidents."
Some of Obama's family — his grandmother, sister and aunts and uncles — joined him Saturday night for a state dinner in his honor. The president said he begged for his family's forgiveness for not being able to travel outside the capital to see them in their homes, citing the presidential security apparatus.
After he is freed from the constraints of the presidency in early 2017, Obama said he hoped to do philanthropic work in Kenya that builds on administrative initiatives. He also promised that he would be joined on a return trip by Michelle Obama and daughters Malia and Sasha, who did not travel with the president on this trip.
Obama said that next time he's back, "I may not be wearing a suit."
Associated Press writers Darlene Superville and Christopher Torchia contributed to this report.
Follow Julie Pace at http://twitter.com/jpaceDC