HELENA, Mont. (AP) — The Montana Supreme Court overturned a $34.9 million judgment against the state in a lawsuit brought by liquor store owners who challenged the way the Department of Revenue reimbursed them for a case discount they were required to give bars.

The owners argued in 2014 that when privatizing state liquor stores in the mid-1990s the Legislature did not fully or equally reimburse the stores for the 8 percent discount, and that lawmakers created a formula that harmed stores that increased their case sales.

In 2015, District Judge Greg Pinski of Great Falls ruled the law setting the reimbursement formula was unconstitutional. Last year he ordered the state to pay $14.8 million in damages for undercompensating store owners, $11.3 million in interest and $8.7 million in attorney fees.

The Supreme Court ruled Wednesday that the Legislature did not intend to fully reimburse store owners for the case discounts, or the 1995 legislation would have been written that way. Lawmakers in 2007 did not act on another bill that called for a full reimbursement, demonstrating that "the Legislature rejected a full reimbursement in favor of a partial offset," Justice Laurie McKinnon wrote in the 7-0 ruling.

Justices noted the bill that created the reimbursement formula was a compromise among all the major groups affected by the privatization of state liquor stores, including employees, agents, liquor licensees, liquor suppliers and the Department of Revenue.

Prior to privatization, the Department of Revenue fully reimbursed state liquor stores for providing case discounts. The change with privatization indicates the Legislature intended to alter the way it reimbursed the required case discounts, McKinnon wrote.

Jonathan McDonald, an attorney for the liquor store owners, said they respect the Supreme Court's decision.

"But we join our clients and the District Court judge in our belief that it is not acceptable for the government to treat its agency stores differently, exacting huge sums from some while fully reimbursing others. Especially when the government admitted its mistake after we filed this case by changing the law in 2015 to treat all of the agency stores the same," McDonald wrote in an email.

The case was brought by Duane C. Kohoutek Inc. and Nobles Inc. of Great Falls, Bucher Sales LLC of Cut Bank and Spirits Plus LLC of Baker on behalf of themselves and other liquor stores.

Revenue Director Gene Walborn said the agency would have had to ask the Legislature to appropriate the $35 million had the state lost its appeal. The Montana Legislature held a special session in November to address an expected $227 million budget shortfall.