The Supreme Court on Monday struck a section of a 1980s law that allows prosecutors to seek stiffer penalties for certain violent crimes involving firearms, finding that the provision does not give clear “fair warning” to would-be offenders.

“A vague law is no law at all,” wrote Justice Neil M. Gorsuch, who was joined by the court’s liberal justices, Ruth Bader Ginsburg, Stephen G. Breyer, Sonia Sotomayor and Elena Kagan.

The 5-to-4 ruling came on what was originally scheduled to be the last day of the Supreme Court’s term. But the justices have not delivered opinions in eight case argued earlier in the term, including what role federal courts play in policing partisan gerrymandering, and whether the Trump administration may add a question about citizenship to the 2020 Census form sent to every household.

The court will be in session again Wednesday.

Apart from the gun-crime decision Monday, the justices made it harder for the public and news media organizations to obtain some commercial information under the Freedom of Information Act (FOIA). The court also announced that it would hear a case next term regarding what health-care insurers say was an underpayment to them under the Affordable Care Act.

In the gun case, Gorsuch assumed the role of the man he replaced, Antonin Scalia, a conservative who sided with liberal justices in similar criminal cases involving laws that lower courts deemed hard to decipher. He also broke with Justice Brett M. Kavanaugh, a fellow nominee of President Trump who wrote a dissent in the case.

As written, the majority said, the statute provides no reliable way to determine which offenses qualify as “crimes of violence.”

“A statute that requires you to imagine how a crime would ordinarily be committed, and then to estimate the risk associated with that ordinary case of the crime, produces more unpredictability and arbitrariness than the Constitution tolerates,” Gorsuch said in announcing the decision.

Kavanaugh said getting rid of a key section of a 33-year-old law is an “extraordinary event” that probably would result in the release of some prisoners.

“They are offenders who committed violent crimes with firearms, often brutally violent crimes,” wrote Kavanaugh, who was joined by Justices Clarence Thomas and Samuel A. Alito Jr., and in part by Chief Justice John G. Roberts Jr.

The case was brought by two men, Maurice Davis and Andre Glover, who were convicted of robbing multiple gas stations in Texas. At trial, the men received additional mandatory prison terms for using shotguns in connection with their crimes.

Kavanaugh said previous decisions eliminating other vague provisions dealt with laws that imposed additional penalties based on earlier convictions. In contrast, the language struck by the court Monday centers on a defendant’s current conduct.

Arun Rao, a former federal prosecutor in Maryland, said the ruling “deprives federal prosecutors of a valuable and frequently used tool to combat violent crime.”

“Congress should now provide a legislative fix through a more carefully crafted statute,” Rao said in an email.

The decision Monday does not entirely strike the enhancement for using or carrying a firearm but gets rid of one of the avenues prosecutors have used to increase penalties.

C. Justin Brown, a criminal defense lawyer in Baltimore, said the provision had allowed prosecutors to effectively turn already long sentences into life sentences by tacking on additional mandatory terms.

He said the ruling would “eliminate some of the most egregious sentences we see in the federal system.”

The case is U.S. v. Davis.

In Food Marketing Institute v. Argus Leader , the court sided with an industry group fighting a South Dakota newspaper’s request for information about the national food-stamp program.

The newspaper asked for data about retail stores that participated in the program, and a lower court said it should be turned over. But in a 6-to-3 ruling, Gorsuch said the information falls into an exception in the law for confidential commercial information.

Breyer, writing in dissent, would have required the stores to demonstrate that releasing the information would have hurt them commercially.

“The whole point of FOIA is to give the public access to information it cannot otherwise obtain,” he wrote.

During the term that will begin in October, the justices said Monday, they will review another controversy involving the Affordable Care Act, this one involving health-care insurers that say the federal government owes them billions of dollars.

The program, creating what is known as “risk corridors,” was one of three strategies built into the 2010 health-care law to try to deter insurers participating in the new marketplaces from mainly seeking customers who are healthy and thus need little medical care.

But insurers say that the government never fully funded the program, and that they are owed $12 billion.

Originally, the program was not required to pay for itself, but, in a 2015 funding bill, congressional Republicans prohibited the Health and Human Services Department from using any of its other resources for the program.