When Ade's aunt learned he was gay, the then 16-year-old Nigerian was made to go through an exorcism to expel "the demon of homosexuality".

"The priest came to the house with candles, holy water and anointing oils. I had to kneel down, holding candles in my hands," recalls Ade, now 25, as he sits in a cafe in Lagos. He does not wish to reveal his full name. "He kept shouting 'Come out! Come out! Come out!' in a fevered voice … I was allowed to go back to church after that but I had to pretend to be straight."

In a country where homosexuality is punishable by up to 14 years in prison, it is no surprise that many of Ade's friends – those who, like him, are both gay and religious – stay away from church altogether for fear of being outed.

However, an alternative could soon be at hand. Ade is helping to resurrect a religious refuge for himself and his friends. He is part of the team restarting House of Rainbow, the country's only gay church, which was forced to close in 2008 after a witch-hunt stirred by exposés in local newspapers.

The Rev Rowland Jide Macaulay, the gay minister who founded the church, is leading the comeback even though he remains in self-imposed exile in London.

"Religion is a backbone to life in Nigeria, so we all want to go to church," he says. "But we don't want to lie to God about who we are."

Macaulay first set up House of Rainbow in 2006, when he openly held Sunday services in a Lagos hotel hall decked out with rainbow flags. A public backlash culminated in members being beaten as they left church. Macaulay fled to the UK after death threats.

This year, he has recruited a small team that includes Ade as his local leader in Lagos. In his voluntary role, Ade started holding prayer sessions and Bible study groups at his house at the end of last month. A full church might be set up again if it is considered safe.

The project could even spread beyond the borders of Africa's most populous country. Macaulay has recently recruited a local leader in Accra, the capital of nearby Ghana. He is considering applications from Rwanda and Zimbabwe.

Religious groups are central to Nigeria's culture of homophobia. Pentecostalism, an evangelical school of Christianity thought to have started in America just over a century ago, has blossomed in southern Nigeria and across Africa in recent decades. The "megachurches" in and around Lagos can attract tens of thousands of worshippers to a single service.

Pentecostal pastors often see gay desire as the work of demons. "You might start casually but, once you get into it, you will be possessed by the spirit," says Emmanuel Owoyemi, a pastor in Lagos.

Meanwhile, in Nigeria's mostly Muslim north, 12 states have adopted sharia law over the last decade. Gay sex carries the death penalty under sharia, although no executions have yet taken place. A national anti-gay marriage bill, which pushes for jail sentences for anyone who even assists gay marriage, has been before Nigeria's parliament since 2009.

Being gay is regarded as an offence across much of Africa. Uganda's parliament continues to debate a proposed law that would introduce the death penalty in some cases. Malawi's president only pardoned a gay couple last year sentenced to 14 years in jail after an international outcry.

Apart from being on the wrong side of the law, many homosexual Nigerians say exclusion from church is one of the hardest parts of being gay.

"We are brought up to believe that you should belong to a religion. We feel that, if we don't go to church, God will not answer our prayers," says a young gay man in Abuja, Nigeria's capital. "When I recently told a friend I was having financial difficulties, he said, 'When did you last go to church?'"

In oil-rich Nigeria, where corruption robs many of even basic services, religious groups provide more than spiritual assistance. Muslim movements such as Izala have built schools in the north, while southern pentecostal groups such as the Redeemed Christian Church of God run universities. "[We] lose out on all these services," says the young man.

Some argue that African homophobia is slowly waning. Marc Epprecht, an expert on sexuality in Africa at Queen's University in Canada, says the continent's growing number of gay rights groups are challenging negative stereotypes.

He adds that despite the bad press it attracts, African homophobia is not markedly stronger than that of poor or patriarchal parts of the Middle East and South America.

Macaulay, however, is not taking any chances this time. Prayer sessions are being held in secret locations. No unknown newcomers are being admitted. He continues to preach via YouTube from London – he thinks it would be unwise to return home. "We have learnt our lesson," he says. "It is a hostile situation."