A 66-year-old nanny arrested by federal immigration agents outside a home in San Francisco’s Diamond Heights neighborhood was freed within hours on Friday after a federal judge ordered her immediate release, according to court filings.

The woman, a Russian national who has lived in the United States for more than 12 years, was detained by U.S. Immigration and Customs Enforcement officers, according to a habeas corpus petition filed on her behalf. Her attorney, who says he was contacted by her employer, added that the woman’s family is still shaken and asked her name not to be used because they fear retaliation.

Ghassan Shamieh, managing immigration attorney representing the detained woman, said his office received a frantic call shortly after the arrest.

“We got a phone call from the employer around 9:15 who called our office frantically saying, ‘Our nanny was just arrested outside of our home. Masked people pulled up in an unmarked car and took her,’” Shamieh said.

Shamieh says despite their requests to see the detainee who spent hours at the Sansome Street processing ICE center, they were denied access.

Shamieh’s team immediately filed a habeas corpus petition in federal court while she was being transported to the California City’s detention center. She was released in Bakersfield Friday night after the court’s order.

A habeas petition is a legal action that challenges the lawfulness of a person’s detention. It asks a federal judge to require the government to justify why someone is being held. If the court finds the detention unlawful, it can order the person’s release.

Immigration attorneys say a record number of habeas petitions have been filed in recent months. In the Northern District of California, federal judges have repeatedly sided with immigrants in these cases, ordering releases when they determined detentions lacked proper legal basis or due process protections.

In this case, Shamieh’s team also filed for a Temporary Restraining Order, which a federal judge granted the same day.

According to the TRO, ICE officers did not present a warrant at the time of arrest and provided no explanation other than telling the nanny she was “in removal proceedings.”

“She has a pending immigration matter, she has legal authorization to work, she takes care of a family with two young kids. She means everything to this family,” Shamieh said.

The judge described it as “inexplicable” that a 66-year-old woman with no criminal history, who has lived in the United States since 2012, was detained without a hearing. The court ordered the government to immediately release her and barred ICE from re-detaining or deporting her without notice and a hearing.

Court records show she was legally admitted to the U.S. on a visitor visa in 2012. She applied for asylum in 2014 and has attended all required immigration hearings, according to filings.

Neighbors in Diamond Heights said they were stunned by the arrest.

“We’ve never heard of any sort of ICE or immigration action here in Diamond Heights. We do have a lot of nannies, so I am concerned,” said resident Marty Grimes.

Another resident, who asked not to be identified, said, nannies from other countries provide a very valuable service, “especially for parents who want to continue their careers. Having a nanny at home enables them to do that, and I think they deserve to be protected as well”, she said.

The federal government has until Feb. 17 to respond to the habeas petition. A hearing is scheduled for Feb. 19 in federal court.

The U.S. Department of Homeland Security and ICE did not respond to requests for comment. They asked NBC Bay Area for a copy of the petition, which was provided along with the detainee’s name.

The detained woman, who has a pending asylum application, has an upcoming hearing on this case set for December 2026.