President Barack Obama has nudged African nations to treat gays and lesbians equally under the law, a position that remains unpopular through much of the continent.

Mr Obama's Kenyan counterpart responded by calling the matter a "non-issue" for his country.

Mr Obama tackled the sensitive issue on his first full day in Kenya, the country of his father's birth. He drew on his own background as an African-American in the US, 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," Mr Obama added during a joint news conference with Kenyan president Uhuru Kenyatta. "When a government gets in the habit of treating people differently, those habits can spread."

Mr 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 Mr Obama in outspoken terms that any overtures on gay rights would not be welcomed in Kenya, where gay sex is punishable by up to 14 years in prison.

Mr Obama's visit to Kenya - the first by a sitting U.S. president - has been long sought by this East African nation where he is widely considered a local son.

Acknowledging that some Kenyans have been frustrated that it took him until the seventh year of his presidency to visit, Mr Obama joked that he didn't want the rest of Africa to think he was "playing favourites".

Still, he noted the US had concerns about violence that erupted in Kenya after its 2007 election. Mr Kenyatta faced charges related to that violence in the International Criminal Court, though those charges were later dropped.