WASHINGTON — The Supreme Court on Monday rejected an effort in Puerto Rico to allow public utilities there to restructure $20 billion in debt, striking down a 2014 Puerto Rico law.

Justice Clarence Thomas, writing for the majority in the 5-to-2 decision, said the law was at odds with the federal bankruptcy code, which bars states and lower units of government from enacting their own versions of bankruptcy law.

Puerto Rico is struggling with $72 billion in debt and has argued that it needs to restructure at least some of it under Chapter 9, the part of the bankruptcy code for insolvent local governments. But Puerto Rico is not permitted to do so, because Chapter 9 specifically excludes it, although it is unclear why.

In 2014, the island tried to get around that exclusion by enacting its own version of a bankruptcy law, intended for its big public utilities, which account for about $26 billion of the total debt. But that attempt, called the Recovery Act, ran afoul of the part of the code that says only Congress may enact bankruptcy laws.