A tax on health insurers is helping pay for President Barack Obama’s health care law, but it’s proving costly to state governments — as much as $13 billion in less than a decade.

The Health Insurance Providers Fee was aimed at insurance companies. The thinking went: Because insurers would gain a windfall of customers, they ought to help pay for the expansion of coverage. Insurers say they have raised prices for individuals and small businesses to cover the new tax.

They are raising their prices to state Medicaid programs, too. The federal government issued guidance in October requiring states to build the tax into what they pay for-profit Medicaid health plans that serve low-income people. The first year’s tax was due to the IRS in September, and state governments are now settling up with insurance companies.

It works like this: State governments pay insurers for the tax. The insurers then pay the tax to the federal government. The federal government then reimburses part of the cost to the states. It might sound absurd, but it’s not amusing to state governments, which lose 54 cents for every dollar of the insurance tax.

“It’s like a merry-go-round with an extra loop in the middle,” said Rebecca Owen of the Society of Actuaries.

The health law tax is not deductible for the insurance companies when they file their corporate income taxes, and state governments must kick in to cover that cost.

“If they’re following the standard of practice, there’s no wiggle room” for states to shift the burden back onto the companies, Owen said.

It’s troubling because more states are turning to private sector Medicaid managed care. An estimated 70 percent of Medicaid patients are covered by these types of plans.

The states with the most managed care will be hurt the most. Florida will pay up to $1.2 billion over 10 years, according to a 2014 report by the actuarial firm Milliman. The same for Pennsylvania. Texas will pay up to $1 billion and Tennessee as much as $884 million. For California, the decade’s total will be up to $798 million, and for Georgia, it will be $647 million.