CAPE TOWN, South Africa — When South African airport officials threatened to send Dr. Paul Semugoma back to his native Uganda, he shook with fear.
Semugoma, an outspoken gay activist, was determined to remain in this country, where he has lived for two years, rather than be sent back to one of Africa's most homophobic countries.
Held by immigration officers after returning to South Africa with an expired visa, he was allowed to stay only after an outcry from human rights groups mindful of new legislation in Uganda calling for life in prison for those who engage in repeated acts of gay sex.
The harshness of the law signed days later by Ugandan President Yoweri Museveni — and similar strictures in more than three dozen African nations — is triggering a profound reaction in Africa.
For every repressive law, there's an answer from African writers, intellectuals, politicians, doctors and activists. Despite the setbacks, gays and lesbians are increasingly coming out in countries where laws are not enforced, penalties are not as harsh or don't exist.
In an open letter last month, former Mozambican President Joaquim Chissano called on all African leaders to protect gay rights. Retired Anglican Archbishop Desmond Tutu of Cape Town compared Uganda's anti-gay law to Nazi Germany's repressions.
Renowned Nigerian writer Chimamanda Adichie chimed in with a powerful condemnation of her country's anti-gay legislation, which was signed into law in January.
But the change was perhaps best illustrated by an essay by prominent Kenyan writer Binyavanga Wainaina, titled "I am a homosexual, Mum," penned partly in anger over laws in Nigeria and Uganda.
Wainaina said he had known he was gay from the age of 5. Placing himself back in his younger years, he said the recognition "comes every few months like a bout of malaria and leaves me shaken for days, and confused for months."
He never told his parents. He didn't touch a man sexually until he was 35, and couldn't use the word "gay" for four years after that.
His essay begins with a story that didn't happen. Instead of his self-absorbed, busy life in South Africa, instead of somehow failing to get to his mother's side in a Nairobi hospital, his essay has him there, head on her shoulder, gently clasping her hand, which is swollen with the effects of diabetes, whispering the truth. She is awake, listening, dying:
Nobody, nobody, ever in my life has heard this. Never, Mum. I did not trust you, Mum. And. I. Pulled air hard and balled it down into my navel, and let it out slow and firm, clean and without bumps out of my mouth, loud and clear over a shoulder, into her ear.
I am a homosexual, Mum.
Dozens of men are behind bars in Africa, awaiting trial on sodomy charges or already convicted under anti-gay legislation that, according to Amnesty International, exists in 38 African countries. Ethiopia is expected to toughen its legislation next week.
The harsh new punishments in Nigeria and Uganda — signed with a populist flourish by Presidents Goodluck Jonathan and Museveni, respectively — seem designed to garner easy support for governments and leaders with poor records, said Dawie Nel, spokesman for Out, a group in Pretoria, South Africa, representing gays, lesbians and bisexual, transgender and intersex people.
In Nigeria, the president's move prompted a flurry of arrests, as well as riots outside a court where men faced trial for engaging in gay sex. In Uganda, activists worry that the law, and the president's accompanying speech branding homosexuality "disgusting," will incite homophobic attacks.
Semugoma says that growing up in Uganda, he knew he was gay. But he was in denial. As a teenager, he joined an evangelical church and convinced himself that "sex was evil." He later immersed himself in medical studies. But his denial eventually flaked away like a coat of bad paint.
"I couldn't hide from myself that I was attracted to other guys," says Semugoma, 43. "I was very lonely. I hid in my books. I hid in my religion, but religion was wearing out. I couldn't talk to anyone about it."
Two years ago, after the slaying of an activist friend, Semugoma left for South Africa, whose constitution guarantees equal rights for gays, lesbians, transgender people and others. He recently took part in an annual gay pride march.
"The one thing Uganda taught me," he says, "is I have to celebrate who I am."
Many of Semugoma's friends in Uganda have moved out of their homes, gone into hiding or fled to Kenya, where lawmakers also are pushing for stronger enforcement of their country's anti-gay legislation. Fear grew after a Ugandan tabloid newspaper, just after the law was enacted, published names and photographs of 200 people it said were gay.
"In Uganda, they're scared," Semugoma says. "They're asking what can they do to get out of the country. Kids are coming out on Facebook saying: 'How can I be gay? I want to kill myself.'"
"If somebody starts a mob, very quickly something terrible can happen. That's the kind of thing people fear. They fear being firebombed in their houses, with the rhetoric of the preachers that we're the most evil people," he adds. "We have all these excuses — religion and tradition — but those are just excuses. [Museveni] was given all the information. He made such a spectacle when he signed it, and the words he used were horrible."
In an address, Museveni said gays could and should modify their behavior, based on a report he commissioned from scientists. But the report says homosexuality has existed in Africa and elsewhere throughout history, is not a disorder and hasn't been successfully changed through "therapies."
In Africa, presidents and church leaders have called gays and lesbians "un-African" and unnatural, comparing them to animals or malarial mosquitoes that need to be fought. Adichie and other African writers say the truth is very different.
"We cannot be a just society unless we are able to accommodate benign difference, accept benign difference, live and let live. We may not understand homosexuality, we may find it personally abhorrent, but our response cannot be to criminalize it," Adichie wrote.
Adichie's recent essay recalled a thin and smiling boy who played with her and other primary school girls. When he was in secondary school, some boys tried to throw him off a second-story balcony. She wrote:
He brushed away their taunts, silently, sometimes grinning an uncomfortable grin ... I imagine now how helplessly lonely he must have felt.
Calling for protection of homosexual rights, Chissano, the former president of Mozambique, said, "As an African who has been around a long time, I understand the resistance to these ideas. But I can also step back and see that the larger course of human history, especially of the past century or so, is one of expanding human rights and freedoms."
One thing difficult to change about Africa is a reluctance to talk about sex.
"You never talk to your parents about sex," Semugoma says. "Never."
But he told his brothers he was gay, and they broke the news to their parents. His father tried to set up marriages with girls and begged Semugoma to father a child, "even a girl child." Finally he told Semugoma it was all right to be gay, "as long as you don't talk about it."
Semugoma left Uganda after the 2011 killing of his gay activist friend David Kato, shortly after a tabloid published his name and photograph under the headline "Hang them!" (Activists do not accept the official version: that Kato was slain by a lover in a domestic quarrel.)
Despite the homophobia in many parts of Africa, Semugoma says, the worst setbacks have often been cathartic, planting the visceral anger and self-belief that drive people to stand up and fight.
At Kato's funeral, a priest railed against homosexuality and villagers refused to allow the dead man's burial. But Kato's friends, many of them gay and lesbian activists, grabbed the microphone from the priest and buried Kato themselves as television cameras rolled.
"It was a defining moment. People were so angry they were not even worried about coming out at that time. It helped us to really come out. It was a moment of anger, but it was cathartic," Semugoma says.
Semugoma came out publicly in 2012 at an international conference on AIDS in New York and has never returned to Uganda. He lives in Cape Town.
"The biggest problem is silence. The longer you keep silent, the more they lampoon you and demonize you. I will speak these things, even if they are very uncomfortable," he says. "I will call them out."