The Supreme Court will decide whether some immigrants locked up longer than six months during deportation proceedings should have a chance to be released.

The justices said Monday they will take up an issue that affects thousands of immigrants detained for months or years without the benefit of a hearing to determine if their confinement is justified.

The Obama administration is seeking to overturn a federal appeals court ruling that said any immigrant detained more than six months is entitled to a bond hearing. The government argues that automatic bond hearings should not extend to immigrants detained at the border or those who commit certain crimes or engage in terrorist activity.

The 9th U.S. Circuit Court of Appeals in San Francisco ruled last year that holding immigrants indefinitely violates their due process rights. The three-judge panel also said the government must prove an immigrant poses a flight risk or danger to the community to justify denying bond.

The government says the case is critical to its ability to control the borders and reduce the risk of terrorism. Requiring a bond hearing within six months would simply encourage more people to cross the border illegally and delay legal proceedings, the Justice Department argued in legal briefs.

The Justice Department says about 38,000 immigrants released on bond between 2010 and 2014 did not return to face removal proceedings. The government detains more than 429,000 immigrants each year, according to U.S. Immigration and Customs Enforcement.

Allowing the lower court ruling to stay in place "creates an incentive for people to make a potentially life-threatening trip to this country, to abuse our legal process to obtain entry into the United States, and then to disappear rather than appear at any removal proceedings," government officials said.

The class action lawsuit involves about a thousand immigrants in California who have been locked up for longer than six months without a bond hearing. They are represented by the American Civil Liberties Union, which says the average class member has been incarcerated 404 days.

The ACLU says requiring mandatory bond hearings every six months does not mean immigrants automatically will be released.

"It merely requires hearings before immigration judges," the ACLU said in legal briefs. "Those judges answer to the attorney general, who has ultimate authority to reverse any release decisions."

The case is Jennings v. Rodriguez, 15-1204.