Iraq's parliament passed a bill on Saturday criminalising same-sex relations, which will receive a sentence of up to 15 years in prison, in a move rights groups condemned as an "attack on human rights".
Transgender people will be sentenced to three years' jail under the amendments to a 1988 anti-prostitution law, which were adopted during a session attended by 170 out of 329 lawmakers.
A previous draft had proposed capital punishment for same-sex relations, in what campaigners had called a "dangerous" escalation.
The new amendments enable courts to sentence people engaging in same-sex relations to between 10 to 15 years in prison, according to the document seen by AFP, in the country where gay and transgender people already face frequent attacks and discrimination.
They also set a minimum seven-year prison term for "promoting" same-sex relations and a sentence ranging from one to three years for men who "intentionally" act like women.
The amended law makes "biological sex change based on personal desire and inclination" a crime and punishes transgender people and doctors who perform gender-affirming surgery with up to three years in prison.
Homosexuality is taboo in Iraq's conservative society, however there had not previously been a law that explicitly punished same-sex relations.
Members of Iraq's LGBTQ community have been prosecuted for sodomy or under vague morality and anti-prostitution clauses in Iraq's penal code.
"Iraq has effectively codified in law the discrimination and violence members of the LGBTI community have been subjected to with absolute impunity for years," said Amnesty International's Iraq researcher Razaw Salihy.
"The amendments concerning LGBTI rights are a violation of fundamental human rights and put at risk Iraqis whose lives are already hounded daily," Salihy added.
The amendments also ban organisations that "promote" homosexuality and punish "wife swapping" with a prison sentence of 10 to 15 years.
"The law serves as a preventive measure to protect society from such acts," lawmaker Raed al-Maliki, who advanced the amendments, told AFP.
He said passing the new amendment was postponed until after Iraqi Prime Minister Mohamed Shia al-Sudani's visit to the United States earlier this month.
The United States and the European Union oppose the law and "we didn't want to impact the visit," he said.
"It is an internal matter and we do not accept any interference in Iraqi affairs."
The US State Department is "deeply concerned" about the legislation, spokesman Matt Miller said Saturday, adding that the law threatens those most at risk in Iraqi society and "undermines the government's political and economic reform efforts."
LGBTQ Iraqis have been forced into the shadows, often targeted with "kidnappings, rapes, torture and murders" that go unpunished, according to a 2022 report by Human Rights Watch and the IraQueer non-governmental organisation.
Iraqi politicians and social media users have increasingly resorted to anti-LGBTQ rhetoric, which stokes further fear among members of the community.
Human Rights Watch's Iraq researcher Sarah Sanbar said the new law change "is a horrific development and an attack on human rights".
"Rather than focusing on enacting laws that would benefit Iraqis -- like passing the draft domestic violence law or draft child protection law -- Iraq is choosing to codify discrimination against LGBT people," she said.