WASHINGTON — The Supreme Court said Tuesday that part of a federal law that makes it easier to deport immigrants who have been convicted of crimes is too vague to be enforced.

The court's 5-4 decision — an unusual alignment in which new Justice Neil Gorsuch joined the four liberal justices — concerns a catchall provision of immigration law that defines what makes a crime violent. Conviction for a crime of violence makes deportation "a virtual certainty" for an immigrant, no matter how long he has lived in the United States, Justice Elena Kagan wrote in her opinion for the court.

The decision is a loss for President Donald Trump's administration, which has emphasized stricter enforcement of immigration law. In this case, President Barack Obama's administration took the same position in the Supreme Court in defense of the challenged provision.

With the four other conservative justices in dissent, it was the vote of the Trump appointee that was decisive in striking down the provision at issue. Gorsuch did not join all of Kagan's opinion, but he agreed with her that the law could not be left in place. Gorsuch wrote that "no one should be surprised that the Constitution looks unkindly on any law so vague that reasonable people cannot understand its terms and judges do not know where to begin in applying it."

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

The case turned on a decision from 2015 that struck down a similarly worded part of another federal law that imposes longer prison sentences on repeat criminals. The majority opinion in that case was one of the last written by Justice Antonin Scalia, who died in 2016 and whose seat Gorsuch filled.

The 2015 decision "tells us how to resolve this case," Kagan wrote.

Trump tweeted later Monday that Congress must take action in the wake of the court ruling.

....Congress – House and Senate must quickly pass a legislative fix to ensure violent criminal aliens can be removed from our society. Keep America Safe! — Donald J. Trump (@realDonaldTrump) April 17, 2018

Tuesday's decision involves James Dimaya, a native of the Philippines who came to the United States legally as a 13-year-old in 1992. After he pleaded no contest to two charges of burglary in California, the government began deportation proceedings against him. The government argued among other things that he could be removed from the country because his convictions qualified as crimes of violence that allowed his removal under immigration law.

Immigration officials relied on a section of immigration law that lists crimes that make people eligible for deportation. The category in which Dimaya's convictions fell is a crime "that, by its very nature, involves a substantial risk that physical force...may be used in the course of committing the offense."

Immigration judges would have allowed Dimaya to be deported, but the federal appeals court in San Francisco struck down the provision as unconstitutionally vague. The Supreme Court affirmed that ruling Tuesday.

The decision does not interfere with the government's ability to deport people who are convicted of clearly violent crimes, including murder and rape, as well as drug trafficking and other serious offenses. The ruling is limited to a category of crimes that carry a prison term of more than a year, but do not otherwise comfortably fit in a long list of "aggravated felonies" that can lead to deportation.

The case was initially argued in January 2017 by a court that was short a member because of Scalia's death and the refusal of Senate Republicans to act on Obama's nomination of Judge Merrick Garland. Deadlocked 4-4, the justices scheduled a new round of arguments once Gorsuch joined the court.