More than 30 African countries, including Uganda, already ban same-sex relations. The new law appears to be the first to outlaw merely identifying as lesbian, gay, bisexual, transgender and queer (LGBTQ), according to rights group Human Rights Watch.
Supporters of the new law say it is needed to punish a broader array of LGBTQ activities, which they say threaten traditional values in the conservative and religious East African nation.
In addition to same-sex intercourse, the law bans promoting and abetting homosexuality as well as conspiracy to engage in homosexuality.
Violations under the law draw severe penalties, including death for so-called aggravated homosexuality and life in prison for gay sex. Aggravated homosexuality involves gay sex with people under the age of 18 or when the perpetrator is HIV positive, among other categories, according to the law.
"Our creator God is happy (about) what is happening ... I support the bill to protect the future of our children," lawmaker David Bahati said during debate on the bill.
"This is about the sovereignty of our nation, nobody should blackmail us, nobody should intimidate us."
The legislation will be sent to President Yoweri Museveni to be signed into law.
Frank Mugisha, a prominent Ugandan LGBTQ activist denounced the legislation as draconian.
"This law is very extreme and draconian ... it criminalises being an LGBTQ person, but also they are trying to erase the entire existence of any LGBTQ Ugandan," he said.
Museveni has not commented on the current proposal but he has long opposed LGBTQ rights and signed an anti-LGBTQ law in 2013 that Western countries condemned before a domestic court struck it down on procedural grounds.
In recent weeks, Uganda authorities have cracked down on LGBTQ people after religious leaders and politicians alleged students were being recruited into homosexuality in schools.
This month, authorities arrested a secondary school teacher in the eastern district of Jinja over accusations of "grooming of young girls into unnatural sex practices".
She was subsequently charged with gross indecency and is in prison awaiting trial.
The police said on Monday they had arrested six people accused of running a network that was "actively involved in the grooming of young boys into acts of sodomy".
Reuters, the news and media division of Thomson Reuters, is the world's largest multimedia news provider, reaching billions of people worldwide every day.Go to: https://www.reuters.com/