WASHINGTON (Reuters) - Conservative Justice Neil Gorsuch sided with the U.S. Supreme Court’s four liberal members on Monday in striking down as unconstitutionally vague a law imposing stiff criminal sentences for people convicted of certain crimes involving firearms.

FILE PHOTO: The U.S. Supreme Court is seen as the court nears the end of its term in Washington, U.S., June 11, 2018. REUTERS/Erin Schaff/File Photo

In the 5-4 decision, the court ruled against President Donald Trump’s administration in declaring that the federal law in question was written too vaguely and thus violated the U.S. Constitution’s guarantee of due process. The court’s four other conservative justices dissented, including Brett Kavanaugh, who like Gorsuch was appointed by Trump.

The court invalidated the firearms convictions of two men prosecuted in Texas on a variety of charges for their roles in a series of 2014 gas station robberies in Texas. Although the robbers were armed, no shots were fired.

The law, the most recent version of which was passed by Congress in 1986, imposed additional penalties on anyone who committed certain violent crimes while in possession of a firearm.

Gorsuch, appointed by Trump in 2017, wrote that laws passed by Congress must give ordinary people notice of what kind of conduct can land them in prison.

“In our constitutional order, a vague law is no law at all,” Gorsuch added.

Kavanaugh, appointed by Trump in 2018, wrote a dissenting opinion expressing surprise at the court overturning a law in use for decades.

“The court’s decision today will make it harder to prosecute violent gun crimes in the future,” Kavanaugh wrote.

Kavanaugh said there was evidence that steep prison sentences have been a contributing factor in a decline in U.S. violent crime.

Gorsuch said Congress could pass a more specific law to address the issue, but added that “no matter how tempting, this court is not in the business of writing new statutes to right every social wrong it may perceive.”

It represented the third ruling in the court’s current term in which Gorsuch has joined the court’s liberals in a 5-4 decision.

The court sided with defendants Maurice Davis and Andre Glover, who were convicted of multiple robbery counts, one count of conspiracy to commit robbery and two counts each of brandishing a shotgun during a crime of violence.

Davis was originally sentenced to 41 years in prison. Glover faced a 50-year sentence. Both likely will now get shorter sentences. The decision does not affect their other convictions.

Monday’s ruling was similar to another 5-4 ruling a year ago in which Gorsuch also joined the liberals in the majority. The court ruled that a law requiring the deportation of immigrants convicted of certain crimes of violence also was unconstitutionally vague.

Gorsuch is ideologically aligned with the late conservative Justice Antonin Scalia, whom he replaced on the court in 2017. Scalia wrote a 2015 ruling that Gorsuch invoked in Monday’s decision that found that a similar provision in a federal criminal sentencing law also was overly broad.

Trump’s Justice Department appealed the case to the Supreme Court after the New Orleans-based 5th U.S. Circuit Court of Appeals last year threw out one of each of the two defendants’ firearm-related offenses.

A Justice Department spokeswoman declined to comment.

The case did not involve the right to bear arms under the U.S. Constitution’s Second Amendment, which the Supreme Court’s conservative justices tend to interpret broadly.

For a graphic on major U.S. Supreme Court rulings, see: tmsnrt.rs/2V2T0Uf