Minnesota counties on the hook for huge tax refunds to Enbridge — through no fault of their own — will be bailed out by the state to tune of nearly $30 million.

The payments are authorized by the tax bill passed by the Legislature early Thursday. Also, another $16 million to $18 million due to Enbridge will be refunded as a part of a tax settlement the company made with the Minnesota Department of Revenue.

That refund will essentially be paid through a credit to Enbridge's property taxes due in the future.

"This was a catastrophic event that I think was averted by bipartisan work," said Matt Hilgart, government relations director for the Minnesota Association of Counties. "We believe that if the Department of Revenue numbers are right, this should make us completely whole."

The 13 counties that host Enbridge's oil pipelines have been on the losing end of court rulings in favor of the big Canadian pipeline operator. Some of the smaller counties that host Enbridge's pipelines have been left liable for budget-busting refunds — with interest.

Enbridge appealed seven years of the state's tax valuations, cases that have bounced between the Minnesota Tax Court the Minnesota Supreme Court. An important Tax Court ruling in May concluded that the state consistently overtaxed the company between 2012 and 2016.

The counties affected by the Tax Court ruling are: Aitkin, Beltrami, Carlton, Cass, Clearwater, Hubbard, Itasca, Kittson, Marshall, Pennington, Polk, Red Lake and St. Louis.

Pipelines, railroads and utilities are taxed differently than other entities. The Revenue Department, not the counties, conduct the valuation. About two-thirds of Enbridge's property taxes flow to the counties, the rest to the state.

The Revenue Department's refund is due Enbridge as part of the settlement that covers tax refunds owed from the state. The department estimates that refund to be about $16 million; Enbridge, closer to $18 million.

The settlement between Enbridge covers tax appeals from 2012 through 2018, even though the Tax Court has not yet ruled on the 2017 and 2018 appeals.

"Our counties have been waiting with bated breath for years on this issue," Hilgart said. He noted, too, that without the fiscal rescue, local governments and school districts would be hurt, too, since they receive portions of tax collections from counties.

The amount of money each county gets depends essentially on the amount of taxable Enbridge property they host. Itasca is the largest recipient, with $5.59 million earmarked from the legislation. Clearwater County is second with $3.69 million; St. Louis County third with $2.78 million.

The legislative relief is particularly important for less-populated counties with small property tax bases like Clearwater and Red Lake County, the latter of which will get $1.9 million. Some smaller counties are facing Enbridge refunds that are so large they couldn't levy their way out of the predicament.

Clearwater and Red Lake were slated to refund more money than they raise annually from all taxpayers. Other counties faced depleting their reserves and/or raising property taxes or possibly cutting services.

As part of the Enbridge settlement, the state and counties do not have to pay interest on refunds for 2017 and 2018. Generally, though, interest charges of 4% due Enbridge are part of the settlement.

"From the beginning we have acknowledged that counties were caught in the middle of this tax valuation issue," Enbridge said in a statement. "We are pleased to have come to an equitable conclusion to this issue."

In recent years, the Revenue Department has been hit with a wave of tax appraisal challenges from pipelines and utilities, with Enbridge's being the biggest. Other challenges have also resulted in unfavorable tax court rulings against the Revenue Department.

Thus, the Enbridge settlement "doesn't solve the long-term issue," Hilgart said.

As part of the tax bill passed Thursday, legislators ordered the Revenue Department to review its methodology for valuing pipelines and utilities.

Calgary, Alberta-based Enbridge runs six pipelines across northern Minnesota to Superior, Wis., and a seventh that terminates in Clearbrook. Together, they comprise the largest conduit of Canadian oil imports into the United States.

Enbridge is in midst of building a new pipeline to replace its Line 3, which is corroding and running at only half capacity. The $3 billion-plus project has sparked bitter opposition from environmentalists and some Indian tribes, but has been supported by many county governments in northern Minnesota.

Enbridge expects New Line 3 to begin transporting oil during the fourth quarter. Once it comes online, the company said it will pay an additional $35 million in property taxes during the pipeline's first year of operation.