An Afghan family of five that had received approval to move to the United States based on the father's work for the US government has been detained for more than two days after flying into Los Angeles International Airport, a legal advocacy group said in court documents filed Saturday.

A federal judge in Los Angeles on Saturday evening issued a temporary restraining order to prevent the mother and children from being transferred out of the state. The order, by Judge Josephine L. Staton of the US District Court for the Central District of California, arrived as they were about to be put on a plane to Texas, most likely bound for a family detention centre there, lawyers said.

Demonstrators at Los Angeles International Airport protest President Trump's travel ban in January. Credit:AP

The scene at the airport was "chaotic, panicked, it was a mess," said Lali Madduri, a lawyer with the firm Gibson Dunn, which is representing the family pro bono. "The whole time the children are crying, the woman is crying. They can't understand what's going on."

The father had arrived Thursday with his wife and three children, ages 7, 6 and 8 months, on Special Immigrant Visas, according to the lawyers' habeas corpus petition filed in court Saturday. Those visas were created by Congress for citizens in Iraq and Afghanistan who have helped the US military or government by working, for example, as drivers or interpreters. Such work often makes Iraqis and Afghans targets in their home countries.