On Monday, President Goodluck Jonathan signed into law the Same-Sex Marriage Prohibition Act, which parliament passed in May.
The law follows a similar one passed in Uganda in December, which imposes life imprisonment for some types of homosexual acts.
"This is the right thing," said the Rev. Musa Asake, general secretary of the Christian Association of Nigeria. "We don't have to drift into a situation where we don't have moral values because someone is giving us money."
Asake was referring to financial incentives from Western nations tied to legal changes on homosexuality.
With the law taking effect immediately, the Nigerian police rounded up scores of gays and lesbians and locked them in jail, according to Amnesty International.
"This is a dangerous move," said the Rev. Michael Kimindu, president of Other Sheep Africa, an organization caring for gays. "The rest of the world should not allow these laws to continue. Those who fear God and love humanity should sit together and ensure that gay people, their families and friends are not trampled on."
Across Africa, homosexuality is often viewed as a violation of cultural and religious values. Gay sex is outlawed in 38 African countries, according to the International Lesbian, Gay, Trans and Intersex Association. In 13 African countries, homosexuality is legal or there are no laws banning it.
In Mauritania, Sudan and northern Nigeria, homosexuality is punishable by death.
Offenders can receive life imprisonment in Uganda, Tanzania and Sierra Leone.
Kimindu, an Anglican priest, said Christian and Muslim leaders are key to challenging public opinion since they use sacred scriptures to justify homosexuality as sin.