(CNN) -- The father, mother and three young children came to the United States with special immigration visas, granted because the father put himself in danger by working with American forces in Afghanistan, lawyers for the family said.
They landed in Los Angeles on Thursday and planned to take a connecting flight to Seattle, where they would settle.
But instead of rolling out the welcome mat, the federal government took them into custody, said Talia Inlender, a senior staff attorney for Public Counsel Law Firm. Federal agents separated the father from the others, held them four days and threatened to send them to detention centers, she said.
Civil rights lawyers intervened. On Monday, four days after they were detained at the airport, a federal judge ordered the family freed from custody.
"It was a victory in a battle that should not have been fought in the first place," Robert Blume, one of the family's lawyers, said at a news conference Monday. "The government swung and missed on this one. They just got it wrong."
The family had been extensively vetted and approved for the special immigration visas (SIV), Blume said. They should never have been held, he said.
So what happened?
Officials with Customs and Border Protection (CBP) and Immigration and Customs Enforcement (ICE) have not explained why the family was placed in custody. Spokespersons for both agencies declined comment.
Court documents on ICE detainees are usually not available for people facing deportation because of executive orders issued by President Donald Trump. Documents filed by family lawyers say ICE and CBP never provided a reason.
Inlender said the family landed at Los Angeles International Airport at midday Thursday and lawyers heard about their plight Friday. On Saturday, lawsuits were filed and custody of the family was transferred from CBP to ICE, she said.
The mother and children -- ages 7, 6 and 8 months -- were held in a downtown hotel and the father was sent to a detention center in Orange County, she said. They're not identified because of security reasons and are called "Does" in the court papers.
During the first two days, CBP wouldn't allow lawyers to talk to the family, Inlender said. Also, the mother doesn't speak English.
The lawyers said the special immigration visas should have cleared the way for the family. The father worked at a US government base where the Taliban took notice of locals who worked there, Blume said.
"His service put not only his own life, but also the lives of his wife and three small children, at risk," the International Refugee Assistance Project said in a petition for a writ of habeas corpus. "The US government created the SIV program specifically to allow families like petitioners to immigrate to the US and live safely."
Background checks take several years, the petition said, because the government wants to make sure the immigrants don't pose a threat to the United States. Plus, having a valid SIV means the State Department and Homeland Security have already determined the family's lives were at risk.
IRAP court papers filed Saturday said, "Yet now, instead of gratefully welcoming Does 1-5 to the country they helped defend, the US government arrested all five family members --including an infant child -- detained them for more than two days, and held them incommunicado while denying them any access to counsel who seek to advise them and inform them of their rights."
Blume said the family was freed after the court hearing in Santa Ana before federal Judge Josephine L. Staton. Video showed them getting into a van outside the courthouse.
"They are now without restriction free to travel, free to find work, free to buy a cup of coffee," Blume said.
™ & © 2017 Cable News Network, Inc., a Time Warner Company. All rights reserved.