The state departments of Social Services and Revenue Services found that the hospital tax enacted in 2011 by the General Assembly and implemented by the two agencies is legal.

The Connecticut Hospital Association asked the two agencies on Nov. 30, 2015, “whether the General Assembly unconstitutionally delegated the setting of the rate and base year of the Hospital’s Tax to the Department of Social Services in violation of the Connecticut Constitution?”

On Friday, the agencies released a 176-page decision concluding the hospitals “have not provided any evidence that the departments acted in an arbitrary or capricious manner or abused their discretion,” in setting the hospital tax.

Michele Sharp, vice president of communications for the Connecticut Hospital Association, said the ruling is “unfortunate but not unexpected.”

The request for the ruling was thought to be the first step in what would likely be a legal challenge in court.

“CHA and Connecticut hospitals intend to pursue every legal option at our disposal as we continue our efforts to challenge the tax,” Sharp said Friday.

The hospital tax now totals “a staggering $556 million a year and constitutes the highest rate of taxation placed on any group in Connecticut. It’s bad public policy,” Sharp said. “The tax results in the loss of hospital services and staff, increases the cost of healthcare, and damages the state’s economy.”

The main question the hospitals asked the departments of Social Services and Revenue Services was whether it was constitutional for a state agency, and not the legislature, to be setting a tax rate.

“DSS did not set the tax rate of the Hospital User Fee,” the decision reads. “Rather, DSS acted within the scope of its statutory mandate and calculated the amount of user fee due from each taxpayer,” the decision reads. It goes onto say that the General Assembly set the tax rate by “setting forth in statute a formula by which the Hospital User Fee would be calculated.”

The decision further found that in the first year of the tax the hospitals actually received more state funding than the total amount they paid in taxes. The formula for the tax remained consistent from 2012 through 2015, but changed in 2016.

In 2012, the first year of the tax, the revenue it generated after the federal matching funds was returned to the hospitals. In subsequent years, however, the state’s payments to the hospitals were reduced drastically, while the tax has remained in place.

In 2015, the 24 hospitals paid $556.1 million in taxes and received only $164.3 million back from the state.

The hospitals argued that the idea of implementing the “user fee” or tax was to increase the amount of federal reimbursement the state receives. In the first few years the state returned most of the money to the hospitals, but as the state’s budget situation worsened they proceeded to keep the revenue.

In 2015, state budget director Ben Barnes let slip a statement that has followed him since. Asked by lawmakers why the administration was increasing taxes on hospitals, Barnes said, “It’s like why do you rob banks? . . . It’s where the money is.”

The Connecticut Hospital Association has a few weeks to decide whether it will appeal the decision to Superior Court.

Since the association has filed the request for an opinion, Bridgeport Hospital, Greenwich Hospital, Yale-New Haven Hospital, and Lawrence + Memorial Hospitals have withdrawn their petitions while other hospitals are still signed on.