WASHINGTON — The government may not freeze assets needed to pay criminal defense lawyers if the assets are not linked to a crime, the Supreme Court ruled Wednesday in a 5-to-3 decision that scrambled the usual alliances.

The case arose from the prosecution of Sila Luis, a Florida woman, on charges of Medicare fraud that, according to the government, involved $45 million in charges for unneeded or nonexistent services. Almost all of Ms. Luis’s profits from the fraud, prosecutors said, had been spent by the time charges were filed.

Prosecutors instead asked a judge to freeze $2 million of Ms. Luis’s funds that were not connected to the suspected fraud, saying the money would be used to pay fines and provide restitution should she be convicted. Ms. Luis said she needed the money to pay her lawyers.

The judge issued an order freezing her assets. That order, the Supreme Court ruled, violated her Sixth Amendment right to the assistance of counsel.