SPRINGFIELD, Ill. — The Illinois legislature on Tuesday ended a day of emotional debate and fierce back-room arm-twisting by passing a deal to shore up the state’s debt-engulfed pension system by trimming retiree benefits and increasing state contributions.

With one of the nation’s worst-financed state employee pension systems — some $100 billion in arrears — Illinois has been the focus of intense attention across the country as states and municipalities struggle to come to grips with their own public pension problems. The compromise reached in Illinois, a staunchly blue state with a strong labor movement that had successfully resisted previous efforts to trim pensions, could provide a template for agreements elsewhere.

The top leaders of both legislative houses, Democrats and Republicans, had cobbled together the bill and pushed strenuously for its passage, supported by the state Chamber of Commerce and the Illinois Farm Bureau. Union leaders and some Democratic lawmakers opposed it, just as strenuously, arguing that the bill fell too harshly on state workers who had paid into their pension plans over the years with the understanding that the benefits would be there when they retired. Some Republicans also opposed the bill, saying it did not trim enough to solve the state’s pension troubles.

“Today, we have won,” Gov. Pat Quinn, who made overhauling the pension system a focus of his administration, said in a statement after the vote. “This landmark legislation is a bipartisan solution that squarely addresses the most difficult fiscal issue Illinois has ever confronted.” He is expected to sign the legislation on Wednesday.