WASHINGTON — The Supreme Court sharply limited the legal protections for corporate whistleblowers on Wednesday, ruling they are not shielded from being fired under a federal law unless they have reported a potential fraud to the Securities and Exchange Commission.

The justices conceded their ruling might “gut” the whistleblower protections that were adopted after the Wall Street collapse in 2008.

Lawmakers had said they wanted to break the “corporate code of silence” that prevented employees from revealing wrongdoing inside their companies.

But the high court, in a unanimous decision, said the Dodd-Frank Act of 2010 defined a protected whistleblower as someone who reported a potential fraud “to the commission,” referring to the SEC.

Justice Ruth Bader Ginsburg said Congress may have wanted to broadly protect whistleblowers, including those who only reveal problems internally to the company’s top executives or its corporate board. But “Dodd-Frank delineates a more circumscribed class” when it defined who was protected from retaliation, she said.

The court’s decision in Digital Realty Trust v. Somers throws out most of a lawsuit brought by a San Francisco executive who says he was fired as a vice president of a real estate investment trust after he filed a complaint with top executives about possible wrongdoing in an Asian branch office.

He did not take his complaint to the SEC before he was fired, but sued in federal court alleging he was fired for revealing possible wrongdoing. He cited both the Dodd-Frank Act and the earlier Sarbannes-Oxley law that followed the collapse of Enron. In both laws, Congress said it wanted to protect whistleblowers. Moreover, the SEC had adopted regulations after the Dodd-Frank Act that said whistleblowers could not be retaliated against for bringing forth evidence of frauds, including through internal reports to their company.

Based on those regulations, a federal judge and the 9th Circuit Court said Somers could proceed with this suit.

But the justices reversed the 9th Circuit and rejected the SEC’s regulations.

“We find the statute’s definition of ‘whistleblower’ clear and conclusive,” Ginsburg said. Its “unambiguous whistleblower definition, in short, precludes the commission from more expansively interpreting that term.”

Wednesday’s ruling shows how the justices — both liberal and conservative — are sometimes devoted to what the late Justice Antonin Scalia called “textualism.” This refers to deciding cases based on a close reading of the text of the law and without regard to Congress’ broader aims in passing the law.

While Congress may have aimed to broadly protect company whistleblowers to ferret out fraud, the text of the statute included a narrow definition of who qualified for protection.