The House of Representatives in Nigeria has voted to ban gay marriage and crack down on same-sex couples who display "public shows" of affection by threatening harsh jail terms of up to 14 years.
The measures also outlaw any groups supporting gay rights.
Under the bill, "persons that entered into a same-gender marriage or civil union contract commit an offence and are jointly liable on conviction to a term of 14 years imprisonment each".
"Any person who registers, operates or participates in gay clubs, societies and organisations or directly or indirectly makes a public show of a same-sex amorous relationship commits an offence and shall be liable to a term of 10 years imprisonment," it conitinues.
MPs unanimously approved the proposal, which has to be signed into law by President Goodluck Jonathan, although it is not clear if he will.
The UK has threatened to stop aid to nations that discriminate against gay people, although the amount sent by Whitehall to Nigeria is minimal.
"I no longer feel safe under this law," said Rashidi Williams, director of Nigeria's Queer Alliance rights group.
"It has the potential to encourage the instigation of violence against gay people and lesbians."
The bill has drawn condemnation from many sources, including Virgin boss Richard Branson who wrote in his blog: "Too sad to comprehend that Nigeria are passing a law in this day and age to put gay people in prison just for being gay."
Chidi Odinkalu, the chairman of Nigeria's National Human Rights Commission, said he only learned about the House's vote after it had been passed. If signed into law, it would be challenged in court, he warned.
"If that's the scope, there will be serious issues," Odinkalu said.
The proposed law could have an immediate effect on some groups sponsored by USAid, an arm of the US government. Some funding goes to groups to combat HIV and Aids in Nigeria - including work with gays and lesbians. That would be criminalised under the proposed law.
Homosexual acts have been illegal in Nigeria since independence in 1960.