New documents reveal that Immigration and Customs Enforcement (ICE) is putting thousands of immigrants into solitary confinement because they’re LGBTQ, disabled, or report abuse from guards, not because they’re violating any rules in detention.

The documents show that ICE used solitary confinement frequently between March 2012 and March 2017, possibly in violation of its own policies. Only half of the thousands of people who had extended stays in solitary confinement were there because they broke a rule.

About one-third of people in solitary confinement have been determined by ICE to suffer from mental illness. Immigrants who attempt suicide are put in solitary.

“We have created and continue to support a system that involves widespread abuse of human beings,” Department of Homeland Security analyst Ellen Gallagher told NBC News. She said she has spent the last five years trying to change the government’s policy, but is now speaking out publicly.

“People were being brutalized.”

Related: 14 LGBTQ couples from the migrant caravan just got married in Mexico

Solitary confinement separates a person in detention from the general population and restricts their privileges. They generally spend 22 hours a day in their cells, are denied visitation and phone calls, and even personal items like books and photos of friends and family.

It can inflict psychological harm that lasts long after it’s over and is associated with night terrors, depression, anxiety, insomnia, and suicide attempts.

“Every time I closed my eyes, when I was trying to sleep, I began to have nightmares, horrible memories, things that I didn’t want to remember,” said Kelly, a transgender woman from Nicaragua who spent four months in the Pine Prairie ICE Processing center in Louisiana.

“It’s still happening to me.”

She said she didn’t break any rules in detention to get sent to solitary confinement.

“The only thing they told me was that it was because of the way I looked,” she said. “They claimed it was for security reasons. I told them from day one that I didn’t want to be locked up almost 24 hours a day, alone in a cell, without medical attention.”

Several states have banned or restricted the practice in prisons, and Barack Obama banned it for juveniles in the federal prison system.

But as the number of people in ICE custody has exploded to a daily average of 50,000 detainees, so have the number of people in solitary confinement.

“Solitary confinement is being used as a first resort, not the last resort,” Gallagher said.

Dulce Rivera, 36, is a transgender woman from Central America, who said that her mother abandoned her when she was 10-years-old and she lived between Honduras and other countries for a while.

In 2000, at age 16, she was granted permanent residency in the U.S., but in 2017 a criminal conviction landed her in an ICE facility.

She stayed there for months since no country would accept her – she didn’t have a birth certificate or any paperwork that showed what country she was from.

While in ICE custody, she was placed in solitary confinement because she allegedly kissed and touched other inmates, allegations that were later determined to be unfounded.

She spent 23 hours a day, alone. “You never know what day it is, what time it is. Sometimes you never see the sun.”

After four weeks of solitary, she made a noose from a blanket and tried to hang herself. A guard passed by her cell and saved her.

When she got back from the hospital, she was put in a green smock that can’t be turned into a noose and put under even more restrictions in solitary.

“They take off all your clothes, and they put you in a cell that is even more terrible.

She was released from ICE custody when her lawyer challenged her detention.

Gallagher said that she has spent years writing memos and contacting lawmakers to change ICE policy, but she is now going public because she believes that she ran out of options.

“This same set of circumstances will not stop” without public action, she said. “And I think it will actually get much worse.”