(CNN) The Supreme Court on Tuesday invalidated a provision of federal law that requires the mandatory deportation of immigrants who have been convicted of some "crimes of violence," holding that the law is unconstitutionally vague.

The case, Sessions v. Dimaya, had originated during the Obama administration but had been closely watched to see if the justices would reveal how they will consider the Trump administration's overall push to both limit immigration and increase deportations.

As expected after the oral argument, Justice Neil Gorsuch joined with the more liberal justices for the first time since joining the court to produce a 5-4 majority invalidating the federal statute. In doing so, Gorsuch was continuing the jurisprudence of Justice Antonin Scalia, who also sided with liberals when it came to the vagueness of statutes used to convict criminal defendants.

Only eight justices heard the case last term after Scalia's death, and in late June, the court announced it would re-hear arguments this term, presumably so that Gorsuch could break some kind of a tie.

President Donald Trump reacted to the ruling on Twitter on Tuesday evening, writing, "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 Congress -- House and Senate must quickly pass a legislative fix to ensure violent criminal aliens can be removed from our society. Keep America Safe!"

Originated under Obama administration

James Garcia Dimaya, a native of the Philippines, was admitted to the United States in 1992 when he was 13 as a lawful permanent resident. In 2007 and 2009, he pleaded no contest to charges of residential burglary in California. In 2010, the Obama administration brought removal proceedings against Dimaya. An immigration judge determined that Dimaya was removable from the US because of his two state court convictions.

The court held that the convictions qualified for an "aggravated felony" under the Immigration and Nationality Act, which authorizes removal of non-citizens who have been convicted of some violent crimes and defines aggravated felony to include "crimes of violence."

Lawyers for Dimaya appealed the removal arguing that it was unconstitutionally vague and that their client never had fair notice that his crimes would result in deportation.

They suggested the reasoning of a 2015 Scalia opinion, which struck a provision of the Armed Career Criminal Act as unconstitutionally vague, should extend to their case.

The Ninth Circuit Court of Appeals ruled in Dimaya's favor.

"The Supreme Court delivered a resounding message today: You can't banish a person from his home and family without clear lines, announced up front. Congress cannot write a mushy standard that leaves it to unaccountable immigration officials and judges to make it up as they go along," said Josh Rosenkranz, an attorney for Dimaya.

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."

In court, arguing for the Trump administration, Deputy Solicitor General Edwin Kneedler said that when it comes to deportation, "I think it is important for the court to understand that immigration provisions and grounds for deportation are often written in very broad and general terms and given content by the executive branch in which Congress has vested authority."

Michael Kagan of the University of Nevada Las Vegas, an expert on immigration law, notes that Dimaya's challenge began when President Barack Obama was still in office and that Tuesday's ruling is "another sign from the court that due process matters when it comes to deportation."

"This ruling is something immigrants can cite to as they argue for more constitutional protections in other areas," he said.

The Justice Department cited the decision as the basis of the need for more law enforcement powers.

"The Justice Department believes that certain crimes committed by an illegal alien, visa holder, or an alien otherwise granted lawful status in the United States, should trigger their removal," said spokesman Devin O'Malley. "Therefore, we call on Congress to close criminal alien loopholes to ensure that criminal aliens who commit those crimes -- for example, burglary in many states, drug trafficking in Florida, and even sexual abuse of a minor in New Jersey -- are not able to avoid the consequences that should come with breaking our nation's laws."

The Department of Homeland Security sounded a similar tune, saying the ruling "significantly undermines" the agency's efforts and alleging the ruling "allows our nation to be a safe haven for criminals and makes us more vulnerable as a result," according to spokesman Tyler Houlton.

Effect on Trump policies

Tuesday's ruling -- which concerns lawful permanent residents -- won't affect the Trump administration from continuing its efforts to arrest and deport undocumented immigrants, but it does signal that the courts will take a skeptical look at efforts seen as limiting due process rights.

The ruling could especially benefit lawful permanent residents who live in the US legally but commit crimes. In limiting the types of crimes that could justify mandatory and automatic deportation, the court decision could give legal immigrants more opportunities to avoid deportation for low-level offenses that qualify as aggravated felonies under some state laws. Some of the most high-profile cases of this type have included veterans of the US military who have committed crimes after returning home from service, including many who battled addiction problems, who were then deported.

The court took particular note of the fact that under the statute, cases concerning "crimes of violence" wouldn't be eligible for discretion, meaning a judge or officials couldn't even decide in special cases to make an exception.

Leon Fresco, an immigration attorney and former top immigration official at Obama's Justice Department, said the court's decision signals that the argument for why an immigrant should be rendered deportable should be absolutely clear.

"In the end, the court made the right decision in recognizing that, if it takes you more than three minutes to explain legally why someone committed a deportable offense, it is probably not fair to treat them as an aggravated felon with no possible avenue for relief from removal," Fresco said.