Nigerian President Goodluck Jonathan has signed into law a measure that bans same-sex marriage and membership in gay organizations.
The law says anyone who participates in gay clubs or "makes public show of a same-sex amorous relationship in Nigeria" commits an offense and faces up to 10 years in prison.
Anyone who enters a same-sex marriage or civil union contract could face up to 14 years in prison.
The new law drew protest Monday from U.S. Secretary of State John Kerry.
In a statement, Kerry said the U.S. is "deeply concerned" about the law, which he said undermines the protections enshrined in Nigeria's constitution, and "dangerously restricts freedom of assembly, association and expression for all Nigerians."
In contrast with many Western countries, anti-gay sentiment remains high in many African countries, and several countries have moved to tighten laws against homosexuality.
Last month, Uganda's parliament passed a bill that would make some homosexual acts punishable by life in prison. That bill is awaiting the signature of President Yoweri Museveni to become law.