LOS ANGELES, Sept. 26 (UPI) — Hundreds of mentally disabled immigrant detainees deported after representing themselves in immigration court may return to the United States for a second chance to contest their expulsion, a judge ruled Friday.

U.S. District Court Judge Dolly M. Gee approved a class-action lawsuit settlement, clearing the way for immigrants with “serious mental disabilities” to request their cases be reopened. If approved, the United States will pay for transportation in some cases.

“Today’s ruling is a victory for due process,” Hector Villagra, executive director of the ACLU of Southern California, said in a statement. “For too long, individuals with mental disabilities were forced to represent themselves in deportation proceedings or allowed to languish in immigration jails.”

The settlement, which applies to immigrants who were detained in Arizona, California and Washington, follows a 2013 ruling that orders legal representation for immigrants with mental disabilities if they are determined incompetent to represent themselves.

In 2010, the American Civil Liberties Union sued the U.S. on behalf of Jose Antonio Franco-Gonzalez and Guillermo Gomez-Sanchez, two immigrants with cognitive disabilities who had been held in immigration jails for years without hearings or attorneys.