WASHINGTON — The Supreme Court on Thursday handed drug companies two significant victories, one limiting suits from people injured by generic drugs and the other striking down a law that banned some commercial uses of prescription data.

In the first case, Pliva v. Mensing, No. 09-993, the court split 5 to 4 along ideological lines in ruling that the makers of generic drugs — which account for 75 percent of prescriptions dispensed nationwide — may not be sued under state law for failing to warn customers about the risks associated with their products.

Two years ago, in Wyeth v. Levine, the court decided the same question in the context of brand-name drugs but came to the opposite conclusion. That decision was based in large part on the fact that such drug companies can sometimes change the labels on their products without permission from the Food and Drug Administration.

Justice Clarence Thomas, writing for the majority on Thursday, acknowledged that in the eyes of injured consumers, the new distinction between generic and brand-name drugs “makes little sense.” But he said it followed from the way the two kinds of companies are treated under federal law.