FORT LAUDERDALE, Fla. — A Florida judge ordered a sheriff’s office on Monday to release a critically ill woman from custody so her mother can visit her in the hospital.

Circuit Judge Barbara Duffy ordered the Broward Sheriff’s Office to release 26-year-old Kristin Carare, the Miami Herald reported .

Lucy Moss told the Herald the sheriff’s office had allowed her to visit Carare twice at the hospital last week, but then barred her from further immediate visits, threatening her with an arrest for trespassing if she tried.

Sheriff’s spokeswoman Keyla Concepcion told The Associated Press on Monday that the sheriff’s office had no choice because Carare was in custody and security protocols had to be followed. She said the sheriff’s office had bent its rules by letting Moss visit outside its normal procedures, but she wanted to spend the night with her daughter and visit any time of the day. She said the fault lies not with the sheriff’s office, but with “the judicial system” for not releasing Carare from custody sooner.

Carare had been jailed for three months awaiting trial on drug possession charges before becoming ill last week. Her mother says she is a heroin addict. Carare will remain at the hospital but she will no longer be an inmate.

Moss traveled to Fort Lauderdale from Cleveland after learning of Carare’s illness, saying it was a “nightmare” when she was not allowed further visits with her daughter.

Moss said Carare became a drug addict as a teenager after her father was fatally shot two hours after she argued with him. Carare moved to Fort Lauderdale in 2014.

“She’s not a criminal. She had an apartment, a car, a job. She started getting high on weed then went to pills just to keep numb,” Moss said.

But then Carare disappeared for a time before being arrested last September on drug possession charges. She was released on bail but was again arrested after a Florida Highway Patrol trooper found her with drugs. A judge ordered her jailed.

“When you are poor and you either have addiction or mental health issues, the number one treatment provider is the jail,” said Howard Finkelstein, Broward County’s head public defender. He said she should have been released again after the second arrest.

“At the very worst, she is somebody that suffers from addiction and has committed the most minimal of criminal offenses,” he said.

Carare’s public defender, Lien Lafargue, said she seemed healthy when he last spoke to her June 18, but a week later she was in the hospital. Her mother said Carare has a heart valve problem, but it hasn’t been determined what has caused her illness.

Moss said her daughter’s 111-pound (50-kilogram) frame has become bloated and even though she is hooked up to numerous machines and monitors, she was also cuffed to her bed.

“I told the deputy, ‘She doesn’t need to be shackled. She’s not going anywhere,'” said Moss about one of her visits. “I want her to pass with dignity. I don’t want her chained to the bed. The deputy said, ‘If she passes, we’ll take them off.'”

The cuffs were removed under the judge’s order.