WASHINGTON – The Supreme Court ruled Tuesday that a law subjecting non-citizens to deportation for crimes of violence is unconstitutionally vague, handing the Trump administration an early defeat — thanks to the vote of Justice Neil Gorsuch.

President Trump's nominee to the high court joined most of the ruling by the court's liberal minority, agreeing that the law failed to define what would qualify as a violent crime. He based his conclusion on a similar decision written in 2015 by his predecessor, Justice Antonin Scalia.

Vague laws, Gorsuch wrote, "can invite the exercise of arbitrary power ... by leaving the people in the dark about what the law demands and allowing prosecutors and courts to make it up. The law before us today is such a law."

The decision did not please the president, who called it a "public safety crisis" in a tweet from Florida during a two-day summit with Japanese Prime Minister Shinzo Abe.

Today’s Court decision means that Congress must close loopholes that block the removal of dangerous criminal aliens, including aggravated felons. This is a public safety crisis that can only be fixed by....

The majority opinion, written by Justice Elena Kagan, was a victory for James Garcia Dimaya, whose two burglary convictions were considered violent crimes under the statute — despite not having involved violence. It was a defeat for the Justice Department, which defended the law under the Trump and Obama administrations.

"The void-for-vagueness doctrine, as we have called it, guarantees that ordinary people have 'fair notice' of the conduct a statute proscribes," Kagan wrote. "And the doctrine guards against arbitrary or discriminatory law enforcement by insisting that a statute provide standards to govern the actions of police officers, prosecutors, juries and judges."

The court's other four conservatives dissented in two separate opinions totaling 47 pages — more than Kagan and Gorsuch wrote for the majority.

"Today's holding invalidates a provision of the Immigration and Nationality Act ... on which the government relies to 'ensure that dangerous criminal aliens are removed from the United States,'" Chief Justice John Roberts wrote.

Justice Clarence Thomas warned that the court's decision could lead to "the invalidation of scores of similarly worded state and federal statutes."

The case was carried over from the high court's 2016-17 term, after the death of Justice Antonin Scalia. With only eight members, the court was unable to render a decision, and the case was rescheduled. Gorsuch was confirmed to the court last April.

During oral argument on the first day of the 2017-18 term in October, Gorsuch wondered how the court could define a crime of violence if Congress did not.

"Even when it's going to put people in prison and deprive them of liberty and result in deportation, we shouldn't expect Congress to be able to specify those who are captured by its laws?" Gorsuch asked Deputy Solicitor General Edwin Kneedler.

The vagueness doctrine is meant to apply in cases in which the criminal or civil penalty is severe. During oral argument, Justice Samuel Alito wondered how to define severity. Gorsuch had a ready answer.

"Life, liberty or property," he said. "It's right out of the text of the Due Process Clause itself."

The court's ruling followed a similar one in 2015, when Scalia wrote an 8-1 decision declaring a section of criminal law targeting armed violence unconstitutionally vague. The clause allowed past convictions to be treated as violent felonies if they involved "conduct that presents a serious potential risk of physical injury to another."

Joshua Rosenkranz, who represented Dimaya at the high court on the 2017 term's first day in October, hailed the verdict.

"This decision is of enormous consequence, striking down a flawed law that applies in a vast range of criminal and immigration cases and which has resulted in many thousands of immigrants being deported for decades in violation of their due process rights,” he said.