IRBIL, Iraq — Iraqi authorities are routinely denying prisoners their rights from arrest through prosecution, according to the United Nations, leaving tens of thousands vulnerable to violence and other forms of abuse while in custody.

A new report, released Tuesday by the Office of the U.N. High Commissioner for Human Rights and the U.N. Assistance Mission for Iraq, details a labyrinth of unfairness, with detainees often denied due process at every turn. Confessions frequently come through torture, it says. Few detainees see a lawyer until they appear in court. In some cases, they do not even know which authority is holding them.

Four years after the U.S.-backed defeat of the Islamic State group here, more than 40,000 inmates are packed in prisons across Iraq’s federal and Kurdish regions. Judicial records and court visits suggest that roughly half were arrested on terrorism charges, then tried in a system that affords little effort to weigh specific evidence against them.

The U.N. report is based on 235 interviews with current or former detainees, as well as discussions with prison staff, judges, lawyers, families of the detainees and other relevant parties.

At least half the detainees said they were tortured during interrogations aimed at eliciting some form of a confession. Human rights groups have criticized the practice, saying that detainees frequently end up signing documents admitting crimes they did not commit.

Methods of abuse include severe beatings, some on the soles of the feet, as well as electric shocks, stress positions and suffocation, the report says. Sexual violence was also reported, with some detainees also making reference to treatment they “cannot speak about.”

During interviews, the Iraqi security agencies most commonly accused of torture or other forms of ill-treatment were the Interior Ministry in federal Iraq, run from Baghdad, and the Asayish in Iraq’s Kurdish region.

The United Nations did not appear to have access to sites run by Iraq’s predominantly Shiite paramilitary groups. In interviews with The Washington Post, former detainees say that similar torture methods are routine within those cells.

While the United States, which backs the government of Iraqi Prime Minister Mustafa al-Kadhimi, frequently criticizes the conduct of militia groups linked to Iran, it rarely comments on abuses and a lack of accountability elsewhere. Washington has provided Iraq with at least $1.25 billion in foreign military financing since 2015.

When a person is arrested by Iraqi security forces, families are initially left with few scraps with which to piece together their fate. In 285 instances of detention that involved interrogation, no interviewee reported to the U.N. that a lawyer was present, and detainees often reported that they had sometimes struggled to let their families know what was happening.

On a recent day, those families lined up inside an office in Iraq’s human rights commission, their sons’ paperwork in hand as they waited for their opportunity to speak. Behind the desk was Faten al-Helfi, a human rights official whose black-and-gold cellphone flashed constantly.

Some of the mothers sat in silence, heads down, twisting nervous hands below their black abayas or mouthing prayers for the sons they had come for. Others were adamant that they should speak next. “We need you to help us,” said one elderly woman, Jamila Mohamed, waving a thick file in her hand. “We documented everything. We just need someone to listen.”

Almost all said their relatives told them they had been tortured in custody. Several of the men, they said, were physically disabled by the abuse.

One woman said she could not even speak about such possibilities. “My son is missing,” she told Helfi. “We need to know where he’s been held.”

For each case, the human rights official directed staff to write letters requesting medical examinations or other answers. What they might elicit in practice remained unclear.

The U.N. report released Tuesday said that although mechanisms exist for registering allegations of torture, authorities often ignore them. Of 1,406 complaints received by Iraq’s High Judicial Council in 2020, only 18 investigations have been closed, and the results are unclear.

“Non-compliance with legal conditions and procedural safeguards not only renders impossible the provision of fair and transparent justice, it also allows space for abhorrent practises such as torture and ill-treatment to prevail,” the report said.

“By enabling the realities of interrogation rooms and places of detention to be hidden from effective legal oversight, a cycle of acquiescence and denial is being perpetuated,” it added.

Mustafa Salim in Baghdad contributed to this report.