The Supreme Court of Canada has upheld regulations that Ontario created to prevent pharmacy chains from selling their own generic versions of prescription medications in place of name-brand drugs.

In a 7-0 decision, the justices said the province's 2010 regulations are a legitimate part of its efforts to control prescription drug costs.

"The 2010 private label Regulations contribute to the legislative pursuit of transparent drug pricing," the court's ruling reads.

"They fit into this strategy by ensuring that pharmacies make money exclusively from providing professional health care services, instead of sharing in the revenues of drug manufacturers by setting up their own private label subsidiaries."

Two of the country's largest drug store chains -- Shoppers Drug Mart, and Katz Group, which owns the Rexall and PharmaPlus chains -- challenged the province's regulations, saying they should be free to sell their own lower-priced generic versions of big-name drugs without government interference.

In 2011, a lower court sided with Shoppers and Rexall, saying the province had no authority to ban pharmacies from selling private label drugs.

But the Ontario Court of Appeal overturned that ruling, saying the regulations were not too harsh. The court also said it agreed that private label generics would reduce competitiveness and drive up drug prices.

While drug prices themselves are capped in Ontario, drug makers have come up with several ways over the years to induce pharmacy chains to buy their products, such as offering them substantial rebates. The costs of these rebates, though, have compelled manufacturers to keep their own prices higher.

Ontario banned these rebates in 2006, hoping drug prices would fall in turn and pharmacies would pass these savings on to consumers. But manufacturers circumvented the ban by paying pharmacies "professional allowances" instead.

The result, said the court, was that drug prices have stayed inflated.

In 2010, Ontario banned these allowances. It also brought in regulations to prevent pharmacies from selling “private label" generic drugs from their own manufacturers.

In Friday's ruling, the Supreme Court agreed with the province that the purpose of the 2010 regulations was to prevent another possible mechanism for circumventing the ban on rebates that had kept drug prices inflated.

"If pharmacies were permitted to create their own affiliated manufacturers whom they controlled, they would be directly involved in setting the Formulary prices and have strong incentives to keep those prices high," the court said.

The regulations are therefore consistent with the purpose of reducing drug costs, the court said as it upheld the appeal.

Shoppers Drug Mart released a statement within minutes of the ruling, saying that while it respects the decision of the Supreme Court of Canada, "it is disappointed with the outcome."