AUSTIN, Texas ― A woman locked at a family immigrant detention center tried to take her own life this month in what legal advocates described as a desperate effort to free her two kids.

Samira Hakimi, an Afghan national, has spent the last six months detained with her two young children despite a federal ruling that dictates they should have been released within three weeks. The case reinforces the longstanding concerns of immigrant rights groups that say asylum-seeking families should not be forced into prolonged detention.

“They told us you will only be a couple of days in there,” Hakimi told HuffPost. “I never thought that I would be detained here for such a long time. That I’m detained here because I’m from Afghanistan and that’s all. But I’m human.”

In Afghanistan, the Hakimi family had established a high school and multi-branch private university that used Western curricula, taught in both English and Dari and offered more than half its scholarships to women, according to lawyers representing Hakimi and her husband.

Since 2013, the Taliban repeatedly threatened the family for its work. To avoid the danger of commuting, the family moved onto the university campus and contracted private security guards that year.

It wasn’t enough for them to feel safe. “We could not go outside,” Hakimi said. “My children could not go to school. We thought they might be kidnapped. This was always in our minds.... They have their lives to live. They should live happy and free from every small thing, going to school and enjoying their lives.”

Last year, they fled Afghanistan with Hakimi’s brother-in-law and his pregnant wife, who were facing similar threats.

In December, the two families crossed into the United States from Mexico through a legal port of entry, where they all asked for asylum. The men were separated and sent to all-male immigrant detention centers, where they remain. Hakimi and her kids, as well as her sister-in-law and her newborn baby, were sent to the South Texas Family Detention Center in the town of Dilley and later transferred to the Karnes County Residential Center outside San Antonio.

Hakimi passed her “credible fear” interview ― the first step toward applying for asylum. It’s common practice for Immigration and Customs Enforcement to free people who pass these interviews so they can pursue their cases in immigration court, but ICE declined to release her and her children. The agency did not respond to a request for comment explaining why it refuses to release them. Hakimi’s sister-in-law is also still at Karnes with her 10-month-old baby.

Drew Anthony Smith via Getty Images The Karnes County Residential Center houses mothers who enter the United States with their children. Most of them seek asylum or other forms of humanitarian exemption from deportation.

Hakimi told HuffPost she had suffered from bouts of clinical depression before being detained. Advocates with RAICES, a nonprofit that provides legal services to detained families, say she had attempted suicide in the past and told medical workers at Karnes that her condition had worsened as her case appeared to stall. Neither medicine nor therapy would alleviate the problem, she argued. Her depression stemmed from remaining locked up in the detention center with her children.

As the months dragged on, she lost hope. “Here, no one talks to us,” Hakimi said. “They don’t give us the reason why I’m detained in here. I never thought that I would be detained here for such a long time.”

Her son came to her one day asking her why other families were allowed to leave but not them. “That was really triggering her,” Amy Fisher, RAICES’s policy director, told HuffPost. “She was crying and really depressed. And she went into this thought process, when she was really low, thinking, ‘Well, if I’m no longer here, maybe my children can be free.’” Kids cannot be held without their parents or guardians in family detention.

After she made an effort to take her own life, she woke up in the medical unit of the detention center and was taken to a nearby hospital, where two members of the detention center staff sat with her continuously.

“I told them, ‘I’m just crying for my children, please,’” she said in a recording with one of her legal providers. “I’m not sick. But they gave me medicine. And they told me take this every four hours, but I didn’t take it anymore.”

Hakimi told her lawyer she did not know what the medicine was. RAICES is requesting her medical records.

The suicide attempt at Karnes occurred the same month as an immigrant detainee’s suicide at the Stewart Detention Center in Lumpkin, Georgia. Jean Jiménez-Joseph, 27, killed himself after spending nearly three weeks in solitary confinement.

Human rights groups have long criticized mental health services at immigrant detention centers. But Fisher said even adequate therapy wouldn’t resolve the problem Hakimi faces.

“There’s no surprise or coincidence that she attempted suicide within days of a young man committing suicide in another detention center,” Fisher said. “There’s no mental health care that can effectively treat someone who is traumatized in a detained setting.”

The Obama administration had all but abandoned the family detention policy by 2009, but hastily resurrected it in 2014 to dissuade a sudden influx of Central American mothers and children from crossing into the United States. Most of them were seeking refuge from violence in El Salvador, Guatemala and Honduras.

U.S. District Judge Dolly Gee ruled in 2015 that the policy violates a longstanding federal settlement called the Flores Agreement, which requires children to be held in the least restrictive setting possible and to generally be released from detention. To comply with the ruling, most families are released from detention within three weeks.

But Hakimi and her children still have no idea when they’ll be freed. The uncertainty of her case likely played a key role in her deteriorating mental health, according to Luis Zayas, the dean of social work for the University of Texas at Austin. Zayas has interviewed dozens of detainees at Karnes and says clinical depression and high levels of anxiety are common there.

“We see it constantly,” Zayas said. “It’s not necessarily an intrinsic form of depression, based on brain chemicals or a longstanding depression ― it’s what we call ‘reactive.’ It’s related to the environment the person is in, especially over a long period of time.”

Zayas had not interviewed the Afghan woman, but evaluated another woman who attempted suicide at Karnes in 2015. He said he saw parallels in their cases. Both of them had histories of depression and suicidal thoughts prior to entering detention.

Suffering through a period of prolonged confinement can push people back to their worst states of mind, particularly if they have a history of mental illness, according to Zayas. The problem is particularly acute with people in family detention, where the vast majority file claims for asylum or other humanitarian exemptions from deportation. “These families aren’t prepared to be there because they’re not criminals,” Zayas said.

“This is what happens when people get desperate,” Zayas added. “This woman is suffering a mental health crisis. But we know where it’s coming from. We know what we can do to stop it.”

If you or someone you know needs help, call 1-800-273-8255 for the National Suicide Prevention Lifeline. You can also text HELLO to 741-741 for free, 24-hour support from the Crisis Text Line. Outside of the U.S., please visit the International Association for Suicide Prevention for a database of resources.