Uganda is likely to pass a law within months that will make homosexuality a capital offence, joining 37 other countries in the continent where American evangelical Christian groups are increasingly spreading bigotry

"Learned behaviour can be unlearned," said David Bahati. "You can't tell me that people are born gays. It is foreign influence that is at work."

Bahati has just presented his anti-homosexuality bill 2009 to Uganda's parliament. The bill, which will be debated within a fortnight and is expected to become law by February, will allow homosexuality to be punishable by death.

"Most people have misunderstood the bill," Bahati told the Observer. "The section of the death penalty relates to defilement by an adult who is homosexual and this is consistent with the law on defilement which was passed in 2007. The whole intention is to prevent the recruitment of under-age children, which is going on in single-sex schools. We must stop the recruitment and secure the future of our children."

There is wide support for Bahati's law which, while being an extreme piece of anti-gay legislation, is not unique. As far as gay rights are concerned, it would appear that much of Africa is going backwards. Nigeria has a similar bill waiting to reach its statute books and already allows the death penalty for homosexuality in northern states, as does Sudan. Burundi criminalised homosexuality in April this year, joining 37 other African nations where gay sex is already illegal. Egypt and Mali are creeping towards criminalisation, using morality laws against same-sex couples.

The Ugandan bill extends existing laws to make it illegal to promote homosexuality by talking or writing about it, and forcing people to tell the authorities about anyone they know who is gay. The bill, said Bahati, 35, an MP from the ruling party, aims to "protect the cherished culture of the people of Uganda against the attempts of sexual rights activists seeking to impose their values of sex promiscuity on the people of Uganda".

He denied reports that international pressure might result in parts of the bill being toned down. "We are not going to yield to any international pressure – we cannot allow people to play with the future of our children and put aid into the game. We are not in the trade of values. We need mutual respect."

But many suspect that it was outsiders who inspired this bill in the first place. In March, Bahati met several prominent anti-gay US Christian activists who attended a conference in Uganda where they pledged to "wipe out" homosexuality. The conference featured Scott Lively, president of California's anti-gay Abiding Truth Ministries and co-author of The Pink Swastika, a book claiming that leading Nazis were gay. Also there was Don Schmierer, on the board of Exodus International, which promotes the "ex-gay" movement, believing people can change their sexuality and be redeemed. The third extremist evangelical to attend was Caleb Lee Brundidge, who is linked to Richard Cohen who believes that psychotherapy can "cure" homosexuality.

Bahati's bill was drawn up within weeks of the conference, but it has only just begun to cause waves within America's powerful evangelical community. Legalising killing gay people has triggered a bad press for the bill.

This weekend, Rick Warren, the most powerful evangelical in America, released a video statement. "As an American pastor, it is not my role to interfere with the politics of other nations, but it is my role to speak out on moral issues," he said, adding that the bill was "unjust, extreme and un-Christian toward homosexuals".

"That is a remarkable statement from Warren," said Mark Bromley, of the Council for Global Equality "But there is still a pattern of homophobia that is being replicated in many parts of Africa."

Lively released a half-hearted condemnation: "It should be no surprise… that modern Ugandans are very unhappy that homosexual political activists from Europe and the US are working aggressively to rehomosexualise their nation." The Ugandan law, he said, was "unacceptably harsh", but he praised those who drafted it. "If the offending sections were sufficiently modified, the proposed law would represent an encouraging step in the right direction… it would deserve support from Christian believers."

Bahati said yesterday that he regretted Warren's retreat. "It's unfortunate that a man of God who has inspired many people across the world can give in to pressure and disappoint them." Around 85% of Ugandans are Christian – 40% Catholics, 35% Anglican. Muslims make up 12% of the population.

In Entebbe last week, 200 religious leaders, under the powerful umbrella group Inter-Religious Council of Uganda, demanded diplomatic ties be severed with "ungodly" donor countries, including the UK, Sweden and Canada, who are "bent on forcing homosexuality on Ugandans".

Joshua Kitakule, the council's secretary-general, said: "Those countries should respect our spiritual values. They shouldn't interfere. All senior religious leaders have been given copies of the bill to read and educate people in churches and mosques."

For Ugandans such as Pastor Martin Ssempa, who organises anti-gay rallies, the bill brings legitimate moral force to bear on the "corrupting influence" from western societies.

For John Bosco Nyombi, 38, it means he is unlikely to ever see his family or his homeland again. "I had a life, a job, a house, a car, all that is gone," he said. The former banker fled Uganda after a crowd of his friends were rounded up and arrested in a police raid on a Kampala gay bar. "They were ordered to give names of others and, of course under pressure, mine was given. I paid money to an agent and fled to the UK."

Nyombi's first asylum bid failed and he was deported back to Uganda. "For six months, I hid, I couldn't go out, see anyone I knew. The newspaper printed a picture of me and revealed my case and the police were trying to find me." Eventually, lawyers persuaded the British authorities that he was in danger and he was allowed back to England, where he now has a job as a care worker.

Ugandan newspapers often out "homos" and the bill will force many more like Nyombi to leave, said Peter Tatchell, veteran gay rights campaigner. "In many cases, these countries are using laws imposed by the British in colonial times. Before that, homosexuality was actually tolerated or accepted in the traditional cultures.

"The right-wing are losing the battle in the US, so they are exploiting the poverty-stricken developing world. The response of the Commonwealth is pathetic. Of the 80 countries who criminalise same sex-relationships around the world, over 40 of them are in the Commonwealth – where is the concern for human rights?"

It is not just Africa where homophobia is rife – Iran and Jamaica have seen homosexuals imprisoned and attacked and many American states have laws against sodomy. In South Africa, gay rights have advanced: its first gay pride march was held in 1995 and it has now legalised civil same-sex marriage.

But for developing nations, the attraction of right-wing organisations with dollars to spend, combined with fears over a creeping "westernisation" of societies, is increasing the demonisation of gay people.

In 2004, Ruben del Prado, co-ordinator of the Joint United Nations programme on HIV/Aids in Uganda, was prematurely transferred out of the country after he held meetings with lesbian and gay groups about preventing HIV/Aids. The Ugandan government later accused him of holding secret meetings with undesirable groups. Since then, NGOs and aid officials have kept silent.

In Britain, Archbishop Rowan Williams, head of the global Anglican communion, has also kept quiet, to the outrage of the Lesbian and Gay Christian Movement. Its chief executive, Rev Sharon Ferguson, said African homosexuals were being abandoned by the church.

"It's horrendous for them," she said. "They are scared. If they are in this country, they are scared for their families. If they are in Uganda, they are living in fear of being imprisoned and beaten. It's no way to live. To ignore this is against our scriptures. It also makes the pastoral role untenable because if a gay person talks to a priest then the priest is breaking the law if they don't report them.

"It is disgusting that Rowan Williams doesn't speak out. How far is he prepared to let this go? Will he say something when they start killing people? When the lesbian and gay population start to disappear, herded away towards another Holocaust?"

Much of the recent anti-gay activity in Africa has been in response to the increased politicisation of gay Africans, many inspired by the introduction of civil partnerships in the west. When Kenyan-born Daniel Chege Gichia, 39, and Charles Ngengi, 40, had a civil partnership ceremony in October at Islington town hall they expected little more than an exuberant reception in a north London bar and a honeymoon break in Brighton.

Instead, they triggered outrage when a reporter from the Daily Nation in Kenya broke the story to a shocked east African audience, reporting one African guest at the wedding as saying: "It is time the Kenyan community woke up to reality: some of us are gay; Kenyans have to get over it."

For days, Kenyan radio, newspapers and blogs fielded strong reactions. One radio station estimated that one in 20 callers wanted to speak in defence of the couple; the rest were full of fury and of condemnation at the couple's "un-African" behaviour.

"When a man mounts another man," raged a headline in the Standard, "the throne of God shakes."

Reporters rushed to Chege's rural home village in Murang'a district to interview distressed relatives. "This thing has really affected the old parents. The mother no longer wants visitors in her homestead and the old man is no longer the same," said neighbour Mary Muthoni, 50.

"Gichia Gikonyo, Chege's father, has all but lost his ability to speak ever since the pictures from the union emerged," reported one paper.

Chege's two brothers, Humphrey and Mwangi, reported harassment and abuse. "People shout that the family's wealth is paid for by homosexuality. The family endures much," one local woman, Lucy Wanjiru, 43, said.

But as the wedding guest said, it also brought home to Kenyans that homosexuals exist and the government responded by saying it would hold a census "with a view to knowing their numbers so that they can be educated on safe sex".

But while some welcomed the acknowledgment that homosexuality existed, others pointed out that a homosexual sex act can carry a 14-year prison sentence in Kenya and wondered how many people might respond to a census.

In Uganda, the ethics and integrity minister sees the uproar surrounding the bill as positive. Uganda was "providing leadership" to the world, said James Nsaba Buturo.

"It is with joy we see that everyone is interested in what Uganda is doing, and it is an opportunity for Uganda to provide leadership where it matters most. So we are here to see a piece of legislation that will not only define what the country stands for, but provide leadership around the world."

It has certainly created some religious unity. It came as the Muslim Tabliq youth revealed plans to form what they called an anti-gay squad, to seek out and expose homosexuality.

Sheikh Multah Bukenya, a Tabliq cleric, said: "It is the work of the community to put an end to bad practices like homosexuality."

But Gerald Sentogo, of Sexual Minorities Uganda, said the bill was inhumane. "It violates every aspect of a human being. I mean, you cannot tell me you will kill me because I'm gay," he said. "How will somebody know about my sexuality unless he comes to my bedroom? You will trust nobody because everyone will become a spy over the other.

"Imagine people fighting over other issues and somebody will say you are a homosexual to get rid of you, and then you are arrested and you spend seven years in jail or life imprisonment."