SPRINGFIELD — The Illinois Senate on Tuesday approved a “compromise” school funding bill in what’s being called a historic move towards reforming the way the state funds public education.

But it was the inclusion of a private school scholarship and tax credit program within the deal that took up most of the debate — both on the House floor on Monday and the Senate floor on Tuesday. Gov. Bruce Rauner will sign the measure on Thursday, according to his office.

The deal was reached in a rare agreement reached last week among the Democratic and Republican leaders, and Gov. Bruce Rauner after months of tug-of-war.

The Senate voted 38-13 after more than 30 minutes of debate. Fourteen Republicans were among those who approved the measure.

After the passage, the governor called it a “historic day for Illinois.”

“For far too long, too many low-income students in our state have been trapped in underfunded, failing schools. The system needed to change. We have changed it. We have put aside our differences and put our kids first,” the governor said in a statement.

Bill sponsor State Sen. Andy Manar, D-Bunker Hill, said he was undecided about whether to support the bill, with its inclusion of the private school scholarship program. He said he drove past children heading onto school buses Tuesday morning: “Is this bill going to help those children that I saw this morning? And the answer is absolutely it will help those children.”

State Sen. Kimberly Lightford, D-Maywood, noted it took years to find a school funding solution and praised the “spirit of compromise.”

“This is what compromise looks like. This is it. A bill that none of us like at 100 percent. This is what we needed to do in order to fix a flawed system that we became recognized for across this country,” Lightford said.

Rauner has vowed to sign the measure. A Rauner spokeswoman said the governor would sign it “as soon as possible.” The governor is planning to hold a bill signing event.

The legislation is intended to put new money for education into the state’s poorest and neediest districts — and to try to ease the state’s reliance on local property taxes to pay for schools. The system has enabled wealthier communities to pump more money into public education while poor districts fall further behind.

But the compromise includes the controversial private school scholarship and tax-credit program that critics have dubbed “vouchers.” The tax credits are opposed by powerful teacher unions, including the Chicago Teachers Union and the Illinois Federation of Teachers, that traditionally have supported Democrats.

The tax-credit program was backed by Rauner, Republicans and Cardinal Blase Cupich of the Archdiocese of Chicago. It would provide tax credits for anyone who donates to organizations that would create scholarship funds for low- and mid-income students attending private schools.

At least for the next five years — when the measure will sunset — donors would get a credit for 75 cents on every dollar they give. Democrats estimated the program would provide scholarships for up to 6,000 students.

State Sen. Daniel Biss, a Democrat who is running for governor, said he wasn’t supporting the measure because of the private school scholarship and tax credit program. He said it “crosses the red line” and sets a “dangerous precedent.”

But State Sen. Dale Righter, R-Mattoon, said the program will offer an option to children “trapped in failing schools.”

“You’re going to give them an avenue to access a reasonable education,” Righter said. “What is not right about that?”

The Illinois House passed the measure in a dramatic fashion on Monday. It took several hours and three roll-call votes. The measure, which initially failed, cleared the chamber 73-34.

The compromise was reached after weeks of negotiations — and was struck as a way to get both Republicans and Rauner on board.

The House failed to pass the compromise measure on the first try — only 14 Democrats voted for it — but that was a largely ceremonial act orchestrated by Democrats to show their disdain of one of the bill’s most controversial aspects: a $75 million private school scholarship and tax-credit program that teachers unions oppose.

Then, House Speaker Michael J. Madigan, D-Chicago, called for an override vote on Rauner’s changes to a Senate education-funding bill — a measure that failed when Republicans refused to go along. That, too, was done to appease many Democrats who for weeks had been advocating for the override.

That set the stage for a successful vote to re-call the compromise bill. This time, it passed — and Rauner took the House floor to shake hands, with both Republican and Democratic lawmakers.

The lengthy bill, totaling about 550 pages, also includes a hold-harmless provision to ensure schools don’t lose money.

The measure includes language that would allow the Chicago Board of Education to raise the city’s property tax levy to bring in $120 million more in new tax dollars to pay for Chicago Public Schools pensions.

But Chicago Ald. Pat O’Connor (40th) said the board would enact such a tax hike only as a last resort, as city homeowners and businesses are “pretty much at critical mass” after being hit with $838 million in property-tax increases to cover a wide range of city-related pension payments.