WASHINGTON, March 19 (Reuters) - The Supreme Court on Tuesday endorsed U.S. government authority to detain immigrants awaiting deportation anytime - potentially even years - after they have completed prison terms for criminal convictions, handing President Donald Trump a victory as he pursues hardline immigration policies.

The court ruled 5-4, with its conservative justices in the majority and its liberal justices dissenting, that federal authorities could pick up such immigrants and place them into indefinite detention at any time, not just immediately after they finish their prison sentences.

The ruling, authored by conservative Justice Samuel Alito, leaves open the possibility of individual immigrants challenging the federal law involved in the case on constitutional grounds if they are detained long after they have completed their sentences.

RELATED: Inside immigration detention center

11 PHOTOS Inside Otay Mesa immigration detention center See Gallery Inside Otay Mesa immigration detention center Detainees are seen at Otay Mesa immigration detention center in San Diego, California, U.S. May 18, 2018. REUTERS/Lucy Nicholson Detainees attend a service in a chapel at Otay Mesa immigration detention center in San Diego, California, U.S. May 18, 2018. REUTERS/Lucy Nicholson Detainees' possessions are seen at Otay Mesa immigration detention center in San Diego, California, U.S. May 18, 2018. REUTERS/Lucy Nicholson Detainees are seen at Otay Mesa immigration detention center in San Diego, California, U.S. May 18, 2018. REUTERS/Lucy Nicholson Detainees are seen at Otay Mesa immigration detention center in San Diego, California, U.S. May 18, 2018. REUTERS/Lucy Nicholson Handcuffs are seen at Otay Mesa immigration detention center in San Diego, California, U.S. May 18, 2018. REUTERS/Lucy Nicholson An ICE officer is seen at Otay Mesa immigration detention center in San Diego, California, U.S. May 18, 2018. REUTERS/Lucy Nicholson Barbed wire is seen through a door at Otay Mesa immigration detention center in San Diego, California, U.S. May 18, 2018. REUTERS/Lucy Nicholson A guard watches a suicidal detainee in a cell at Otay Mesa immigration detention center in San Diego, California, U.S. May 18, 2018. REUTERS/Lucy Nicholson A detainee stands in a cell at Otay Mesa immigration detention center in San Diego, California, U.S. May 18, 2018. REUTERS/Lucy Nicholson Detainees are seen at Otay Mesa immigration detention center in San Diego, California, U.S. May 18, 2018. REUTERS/Lucy Nicholson Up Next See Gallery Discover More Like This HIDE CAPTION SHOW CAPTION of SEE ALL BACK TO SLIDE

In dissent, liberal Justice Stephen Breyer questioned whether the U.S. Congress when it wrote the law "meant to allow the government to apprehend persons years after their release from prison and hold them indefinitely without a bail hearing."

The Trump administration had appealed a lower court ruling in the case that favored immigrants, a decision it said would undermine the government's ability to deport immigrants who have committed crimes. Trump has backed limits on legal and illegal immigrants since taking office in January 2017.

The plaintiffs included two legal U.S. residents involved in separate lawsuits filed in 2013, a Cambodian immigrant named Mony Preap convicted of marijuana possession and a Palestinian immigrant named Bassam Yusuf Khoury convicted of attempting to manufacture a controlled substance.

Under federal immigration law, immigrants convicted of certain offenses are subject to mandatory detention during their deportation process. They can be held indefinitely without a bond hearing after completing their sentences.

(Reporting by Lawrence Hurley; Editing by Will Dunham)

More from :

Kellyanne Conway says 'shut up and pray' after New Zealand massacre

Supreme Court agrees to rule quickly on citizenship question on census

Ginsburg makes 1st public appearance since cancer surgery