SEATTLE (Reuters) - A federal judge in Seattle on Friday ruled that a Mexican immigrant with a work permit who is being held by immigration officials must be allowed to argue for his release from U.S. custody while court proceedings over his arrest move forward.

Daniel Ramirez Medina, 23, who received permission to work in the United States under President Barack Obama’s Deferred Action for Childhood Arrivals (DACA) program, was arrested last week at his father’s home near Seattle by Immigration and Customs Enforcement (ICE) officers, according to a lawsuit he filed challenging his detention. The lawsuit said he was brought to the United States illegally as a child and given a work permit during the Obama administration.

ICE has alleged that Ramirez has gang ties and should be deported, but Ramirez’s lawyers have filed court papers denying that he has any gang involvement or criminal record and saying he should not have been targeted for removal.

Ramirez’s lawyers have said this could be the first time under U.S. President Donald Trump that a person covered by DACA has been taken into immigration custody.

At a hearing in federal court in Seattle on Friday, U.S. Magistrate Judge James Donohue declined to immediately release Ramirez, but told lawyers for the Justice Department that Ramirez should receive a prompt bail hearing before an administrative immigration court.

“I’m not going to tell the immigration judge how to conduct his or her hearing, just that it must happen by one week from today,” Donohue said.

Donohue also asked both sides to file briefs on whether Donohue has ultimate authority to hear Ramirez’s legal challenge. The Justice Department argues the entire case should be heard in immigration court.

Slideshow ( 6 images )

“I recognize the unusual nature of this case, and I recognize that there are many people who are in similar situations,” Donohue said, adding: “But the court has to make sure that it has jurisdiction.”

DACA, established by Obama in 2012, allows those brought to the country while young to attend school and work. The program protects from deportation some 750,000 people who were brought to the United States illegally as children and are sometimes called “dreamers,” in reference to the Development, Relief and Education for Alien Minors (DREAM) legislation that failed to pass.

At a news conference on Thursday, Trump promised that his administration would “deal with DACA with heart.” He said the issue was a tough one because, while a majority of those benefiting from the program are “absolutely incredible kids,” others are “gang members, and they’re drug dealers, too.”

Dr. Roberto Dondisch, Mexico’s consul in Seattle, attended Ramirez’s hearing on Friday and said the Mexican government has been following the case to ensure Ramirez’s due process rights are protected.

Dondisch said he was happy to hear Trump’s words on DACA, and that his government has not seen a dramatic increase in enforcement targeted toward DACA recipients.

“The DACA program has proved to be a very important program for a lot of amazing kids,” Dondisch said.

About 150 protesters assembled outside the Seattle federal courthouse on Friday in support of Ramirez, who did not appear in the courtroom.