NAIROBI, Kenya—Widespread celebration of President Barack Obama’s visit to a country teeming with national pride over an American leader considered a local son was briefly overshadowed Saturday by a public disagreement with his Kenyan counterpart over gay rights.

In an awkward moment of tension, Mr. Obama condemned Kenya’s treatment of gays and lesbians as “wrong—full stop” while standing alongside Kenyan President Uhuru Kenyatta during a joint news conference.

...