Several Supreme Court justices strongly suggested during oral arguments Tuesday that Vermont’s attempt to restrict the use of drug prescription records for marketing purposes violates corporate free-speech rights.

Vermont’s law is aimed at so-called data miners, companies that buy prescription records from pharmacies — minus patient identifying information — and sell them. The most lucrative sales are to drug companies, which use the information to target doctors to try to persuade them to order drugs other than the ones they are currently prescribing.

Vermont Assistant Attorney General Bridget C. Asay told the court that the state’s interest is to “allow doctors to decide whether this information that they’re compelled to provide to pharmacies may be used in marketing that is directed at them.”

But she faced a barrage of questions from skeptical justices about whether the state’s goal was simply to make it harder for drug manufacturers to convince doctors that their drugs should be prescribed instead of cheaper generic drugs.

“The state is interested in promoting the sale of generic drugs and correspondingly to reduce the sale of brand-name drugs,” Justice Ruth Bader Ginsburg said. “And if that’s the purpose, why doesn’t that run up against what this court has said — that you can’t lower the decibel level of one speaker so that another speaker, in this case the generics, can be heard better?”

Chief Justice John G. Roberts Jr., who along with Justice Antonin Scalia was one of Asay’s most persistent questioners, said the state was stacking the deck against the drug manufacturers.

“You want to lower your health-care costs, not by direct regulation, but by restricting the flow of information to the doctors, by — to use a pejorative word — by censoring what they can hear,” Roberts said.

Asay insisted that drug manufacturers are still free to pitch any message they want, but that doctors don’t want their histories of prescriptions to be used to target them.

There’s no doubt that pharmaceutical companies have an easier time if they have such information, she said, but “they have no First Amendment right to demand it, just as they have no right to demand access to the doctor’s tax returns, his patient files, or to their competitors’ business records.”

Washington lawyer Thomas C. Goldstein, representing IMS Health Inc., which buys the data, countered that the government may not restrict the speech of one side in the “marketplace of ideas” to favor another.

“If the message is accurate . . . the drug companies can go make their pitch,” Goldstein said. “Vermont can come along and make the opposite pitch. Terrific. So can insurance companies.

“But what you can’t do is have a rule that says one side is going to have a much harder time getting to their audience.”

The federal government and 35 states are siding with Vermont in the fight, which has split lower federal courts.

The U.S. Court of Appeals for the 2nd Circuit, in New York, struck down Vermont’s law. The U.S. Court of Appeals for the 1st Circuit, in Boston, upheld similar legislation in New Hampshire. Both the states and the companies on the other side of the conflict asked the high court to decide the issue.

IMS Health and other companies that collect data from pharmacies say it helps law enforcement and public health officials by locating areas where certain illnesses are concentrated and to identify doctors who overprescribe certain drugs, such as narcotics.

The companies profit by selling the information to drug manufacturers, and states say it increases health-care costs by urging doctors to prescribe name-brand drugs instead of generics.

The case is Sorrell v. IMS .