The Supreme Court on Friday found that prosecutors have to prove that an individual alleged to have illegally possessed a firearm must know that they are part of a group banned from having the gun in the first place.

In a 7-2 ruling, the justices sided with United Arab Emirates citizen Hamid Rehaif, who shot firearms at a gun range after he was dismissed from college over bad grades and told that his immigration status under his student visa would be terminated.

ADVERTISEMENT

Federal law bans undocumented immigrants from possessing guns, and prosecutors charged Rehaif with that crime. The judge in the case told the jury that prosecutors did not need to prove that Rehaif knew he was in the country illegally, which he disputed.

Justice Stephen BreyerStephen BreyerREAD: Supreme Court justices mourn death of Ginsburg, 'an American hero' Ginsburg death sets up battle over future of court Trump's Supreme Court list reveals influence of Clarence Thomas MORE wrote in the majority opinion that prosecutors do need to prove that Rehaif knew of his immigration status, and that he would therefore be banned from possessing a gun.

"To convict a defendant, the government therefore must show that the defendant knew he possessed a firearm and also that he knew he had the relevant status when he possessed it," Breyer wrote.

Justices Ruth Bader Ginsburg Ruth Bader GinsburgTrump 'no longer angry' at Romney because of Supreme Court stance Fox News poll: Biden ahead of Trump in Nevada, Pennsylvania and Ohio On The Money: Anxious Democrats push for vote on COVID-19 aid | Pelosi, Mnuchin ready to restart talks | Weekly jobless claims increase | Senate treads close to shutdown deadline MORE, Sonia Sotomayor Sonia SotomayorToomey, swing state Republican, supports Senate moving on Trump Supreme Court nominee Names to watch as Trump picks Ginsburg replacement on Supreme Court READ: Supreme Court justices mourn death of Ginsburg, 'an American hero' MORE, Elena Kagan Elena KaganREAD: Supreme Court justices mourn death of Ginsburg, 'an American hero' Democrats, advocates seethe over Florida voting rights ruling Supreme Court denies push to add Green Party candidates to Montana ballot MORE, Neil Gorsuch Neil GorsuchAbortion stirs GOP tensions in Supreme Court fight Poll: 59 percent think president elected in November should name next Supreme Court justice The Hill's Morning Report - Sponsored by Facebook - Trump, GOP allies prepare for SCOTUS nomination this week MORE, Brett Kavanaugh Brett Michael KavanaughTrump faces tricky choice on Supreme Court pick The Hill's 12:30 Report: Trump stokes fears over November election outcome The Hill's Morning Report - Sponsored by Facebook - Trump previews SCOTUS nominee as 'totally brilliant' MORE and Chief Justice John Roberts joined the majority opinion.

Right-leaning Justices Samuel Alito Samuel AlitoAbortion, gun rights, ObamaCare at stake with Supreme Court pick READ: Supreme Court justices mourn death of Ginsburg, 'an American hero' Ginsburg death sets up battle over future of court MORE and Clarence Thomas Clarence ThomasGOP senator attacks Biden: 'I'm not sure what he recalls' Abortion, gun rights, ObamaCare at stake with Supreme Court pick Rush Limbaugh encourages Senate to skip hearings for Trump's SCOTUS nominee MORE dissented.

In the majority opinion, Breyer pushed back against the government's argument that lawmakers don't typically require prosecuted individuals to know their own status. He said the statutes invoked by the government in arguments "differ significantly from the provisions at issue here."

"As we have said, we normally presume that Congress did not intend to impose criminal liability on persons who, due to lack of knowledge, did not have a wrongful mental state. And we doubt that the obligation to prove a defendant's knowledge of his status would be as burdensome as the government suggests," the opinion reads.

Alito was highly critical of the ruling in the dissenting opinion, noting that the federal gun statute at hand applies to individuals like convicted felons, stalkers and those who commit acts of domestic violence.

"Today's decision will make it significantly harder to convict persons falling into some of these categories, and the decision will create a mountain of problems with respect to the thousands of prisoners currently serving terms" for convictions under that law, he argued.

Alito also took issue with the argument that Rehaif may not have known he was in the country illegally, and criticized the court for agreeing to hear the case in the first place.

And he warned that the ruling could have ramifications for future cases on immigration.

"Serious problems will also result from requiring proof that an alien actually knew—not should have known or even strongly suspected but actually knew—that his continued presence in the country was illegal," Alito wrote.