SINCE his chapter went online, Mr. Wainaina (pronounced wye-NYE-na) said he had been getting messages of support, both public and private, from friends, relatives and even a retired Roman Catholic priest who was close to the family.

“Someone who was in high school with me who I haven’t seen or talked to in years, you know, sent me a private message saying, ‘I’m a cop now, so if you need any help, give me a call,' ” Mr. Wainaina said.

It was generous, and in a way comforting, but also a sign of the severity of discrimination and public insults, blackmail and beatings gay people in Kenya still face, said Peter Njane, a member of the task force for the Gay and Lesbian Coalition of Kenya. “The kind of oppression we go through, it forces us to come out and say who we are.”

It is not just Kenya. On his visit to Africa last year, President Obama found himself trading barbs with President Macky Sall of Senegal. After Mr. Obama praised the United States Supreme Court decision to strike down the Defense of Marriage Act, Mr. Sall retorted, “We are not ready to decriminalize homosexuality.” The news media and public in Senegal, where gay sex is illegal and gays are often persecuted, celebrated his defiance.

Mr. Njane said that while the coalition applauded Mr. Wainaina’s decision to come out, there had been “a lot of negativity on social media.” Some compared gays to pedophiles, while others made crass jokes or uncomfortable statements about gay sex, calling it “weird” and “unimaginable.”

“I blame the parents!” one Kenyan Twitter user said, for giving him an uncommon name like Binyavanga.

He was born Kenneth Binyavanga Wainaina, and his family still calls him Ken. But “the exotic” of the name Binyavanga “gave me a thrill,” he said, and he began going by his middle name.