Nigeria has outlawed same-sex marriage and civil unions in a bill approved by president Goodluck Jonathan, according to his spokesman.
The Same Sex Marriage (Prohibition) Bill 2013, called "discriminatory" by Amnesty International, sets jail terms of up to 14 years for anyone entering gay marriage or civil partnership and also bans LGBT organisations altogether.
"I can confirm that the president has signed the bill into law," Goodluck Jonathan's spokesman Reuben Abati told AFP.
Abati said the bill, adopted by the Senate in 2011, was signed by Goodluck Jonathan "because it is consistent with the attitude of most Nigerians towards homosexuality".
"More than 90 percent of Nigerians are opposed to same sex marriage. So, the law is in line with our cultural and religious beliefs as a people," he added.
"And I think that this law is made for a people and what (the) government has done is consistent with the preference of its environment."
Homosexual acts are already illegal in Nigeria, a highly religious society with its 170 million people divided between Christian and Muslim faiths.
Under the new legislation, those who contract a same-sex marraige or civil union can be sentenced to 14 years in prison. Anyone who registers, operates or takes part in gay organisations or makes a public show of a same-sex relationship will also be punishable to up to 10 years in prison.
Amnesty said the bill would put "a wide range of people at risk of criminal sanctions".
The law follows a similar legislation approved by MPs in Uganda. On 20 December the country's parliament passed the Anti-Homosexuality Bill, which extends the current penalty of life imprisonment for anal sex to all other same-sex acts, including kissing and touching.
Originally introduced by David Bahati in 2009, the Ugandan bill presents jail terms of five to seven years for promoting homosexuality and a life prison sentence for "aggravated homosexuality", which includes acts committed with children, by HIV-positive individuals, or by authority figures.
In its original form, the bill carried the death penalty for certain homosexual acts.
It was temporarily dropped during 2011, after an international outcry that followed the brutal murder of gay activist David Kato.
After being passed in parliament the bill needs to be signed by president Yoweri Museveni - who could face international pressure and pullout of foreign aid if the bill is not amended.