BAGHDAD, IRAQ -- Human rights groups and diplomats criticized a law that was quietly passed by the Iraqi parliament over the weekend that would impose heavy prison sentences on gay and transgender people.

U.S. State Department spokesperson Matthew Miller said in a statement that the law passed Saturday 鈥渢hreatens those most at risk in Iraqi society鈥 and 鈥渃an be used to hamper free-speech and expression.鈥 He warned that the legislation could drive away foreign investment.

鈥淚nternational business coalitions have already indicated that such discrimination in Iraq will harm business and economic growth in the country,鈥 the statement said.

British Foreign Secretary David Cameron called the law 鈥渄angerous and worrying.鈥

Although homosexuality is taboo in the largely conservative Iraqi society, and political leaders have periodically launched anti-LGBTQ+ campaigns, Iraq did not previously have a law that explicitly criminalized it.

The law passed Saturday with little notice as an amendment to the country鈥檚 existing anti-prostitution law. It imposes a sentence of 10 to 15 years for same-sex relations and a prison term of one to three years for people who undergo or perform gender-transition surgeries and for 鈥渋ntentional practice of effeminacy.鈥

It also bans any organization that promotes 鈥渟exual deviancy,鈥 imposing a sentence of at least seven years and a fine of no less than 10 million dinars (about $7,600).

A previous draft version of the anti-prostitution law, which was ultimately not passed, would have allowed the death sentence to be imposed for same-sex relations.

Iraqi officials have defended the law as upholding societal values and portrayed criticisms of it as Western interference.

The acting Iraqi parliamentary speaker, Mohsen Al-Mandalawi, said in a statement that the vote was 鈥渁 necessary step to protect the value structure of society鈥 and to 鈥減rotect our children from calls for moral depravity and homosexuality.鈥

Rasha Younes, a senior researcher with the LGBT Rights Program at Human Rights Watch, said the law鈥檚 passage 鈥渞ubber-stamps Iraq鈥檚 appalling record of rights violations against LGBT people and is a serious blow to fundamental human rights, including the rights to freedom of expression and association, privacy, equality, and nondiscrimination.鈥

A report released by the organization in 2022 accused armed groups in Iraq of abducting, raping, torturing, and killing lesbian, gay, bisexual, and transgender people with impunity and the Iraqi government of failing to hold perpetrators accountable.

A group of Iraqi lawmakers said Sunday that they had launched a campaign to expel U.S. Ambassador Alina Romanowski, accusing her of interfering in the country鈥檚 internal affairs after she issued a statement condemning the legislation.

Iraqis interviewed Sunday expressed mixed views.

Baghdad resident Ahmed Mansour said he supports the legislation 鈥渂ecause it follows the texts of the Quran and the Islamic religion by completely prohibiting this subject due to religious taboos.鈥

Hudhayfah Ali, another resident of Baghdad, said he is against it 鈥渂ecause Iraq is a country of multiple sects and religions.鈥

"Iraq is a democratic country, so how can a law be passed against democracy and personal freedom?" he said.