NEW YORK (Reuters) - Connecticut lawmakers on Thursday passed a two-year $41.3 billion budget, nearly four months after it was due, that is expected to help capital city Hartford avoid bankruptcy through state aid provisions.

FILE PHOTO: Dannel Malloy, Governor of Connecticut speaks to mourners gathererd inside the St. Rose of Lima Roman Catholic Church at a vigil service for victims of the Sandy Hook Elementary School shooting in Newtown, Connecticut, December 14, 2012. REUTERS/Andrew Gombert/Pool/File Photo

The budget for fiscal years 2018 and 2019 closes a $3.5 billion deficit over the two years, in part with tax and fee hikes on tobacco products, ride shares and low-income working families.

It also raids a host of funds - for everything from school bus seats to clean energy and tobacco cessation - for money that will be swept into the general fund.

The state Senate passed the nearly 900-page legislation early on Thursday morning, with the House following suit later in the day.

It was not immediately clear whether Governor Dannel Malloy, a Democrat who has said he will not seek a third term in office, would sign it. He vetoed a previous budget a month ago.

In a statement, Malloy spokeswoman Kelly Donnelly said the governor and his staff would analyze the bill but had “uncovered egregious problems” with a tax increase on hospitals that could knock the budget more than $1 billion dollars out of balance.

Raising hospital taxes would allow the state to get more federal Medicaid reimbursement, with the tax revenues to be returned to the hospitals.

“If there’s a problem, we’ll fix it,” said House Minority Leader Themis Klarides, a Republican, about the hospital tax in a televised press conference after the vote.

The budget contains aid for Hartford, which has said it could file for bankruptcy without extra funding to help close its own $50 million shortfall.

That funding would come with strings attached in the form of a fiscal oversight board.

Connecticut’s towns, schools and nonprofit service providers have grappled for months with growing uncertainty as they wait for state funding that helps them operate.

When the fiscal year began on July 1 without a budget, Malloy took control of spending through an executive order and enacted steep cuts.