STATE HOUSE — A controversial bill tying an increase in the cap on charter school enrollment with significant new funding for all types of public education passed the Senate on Thursday, but not before senators added a controversial local control measure to a bill already unpopular with charter school advocates.

The Senate voted 22-13 in favor of the legislation crafted over the course by a group of four senators tasked by Senate President Stanley Rosenberg with producing education bill that could pass that branch in the face of a ballot initiative backed by Gov. Charlie Baker that would expand charter schools in Massachusetts.

A charter school expansion bill failed in the Senate two years ago, and the legislation approved on Thursday links a gradual increase in the cap on enrollment with new investments of more than $200 million a year in public education.

The cap, under the bill, would climb half a percentage point a year for 10 years to 23 percent of net school spending provided that the Legislature starting in fiscal 2019 fully funds a new foundation budget formula for all public schools that would cost an estimated $203 million to $212 million annually for seven years.

The bill appears targeted for significant revisions when it reaches the House. House Speaker Robert DeLeo has acknowledged that there are parts of the Senate bill he likes, including a new unified student enrollment policy for charters and district schools, but House leaders also have concerns.

Baker, a charter school expansion proponent, has also voiced concern with the Senate approach, and Education Secretary Jim Peyser in statement after the Senate vote said he hopes the House will produce a “more focused bill that ensures children and families in our lowest performing districts have greater access high-quality public charter options.”

“This bill would effectively place a moratorium on new public charter schools and puts insurmountable obstacles between thousands of children and high quality public education. It offers no relief to the 34,000 children stuck on wait lists while placing a financial burden on cities and towns,” Peyser said.

Sen. Karen Spilka, the chair of Ways and Means who participated in the informal working group, told her colleagues that a proposed ballot question on charters that would authorize up to 12 new charters a year outside the cap in low-performing districts would cost $1.5 billion over six years and affect just 4 percent of students in Massachusetts.

The legislation before the Senate, she said, would cost more than $1 billion over seven years and affect all students.

“I ask you, which one would you choose, to help 4 percent or help 100 percent?” Spilka said, later adding, “We need to give all our children the chance to rise together.”

Sen. Patricia Jehlen, a Somerville Democrat, said the bill would also ensure that charter schools adhere to the “same standards of inclusion” as district schools.

However, even Sen. Marc Pacheco, who ultimately supported the bill after expressing some misgivings, conceded near the end of the six-hour debate that the Senate bill was unlikely to mollify pro-charter advocates and he predicted the question of charter expansion would go before voters in November regardless of the Senate’s efforts.

“I do think it’s going to the ballot,” Pacheco told the News Service after the vote. “Anything that comes back from the House that has less than what we sent over I believe will be dead on arrival.”

Senate Minority Leader Bruce Tarr, who voted against the bill, repeatedly expressed his concern that the bill did not identify a single funding source for the $200 million commitment it would make to public education, suggesting Senate leaders were counting instead on passage of the so-called millionaire’s tax that could go before voters in 2018 and generate as much as $1.9 billion in new revenues.

He also called the bill “unfortunately not balanced,” and said it features “more poison pills in it than Dr. Kevorkian’s apothecary.”

Tarr’s comments came before the Senate voted 24-10 to approve a Sen. Michael Moore amendment that would give local school committees the right to vote on whether a charter school in their district should receive public funding from the district for students that opt to enroll in the charter. If a school committee voted against, Moore said the charter school could still operate, but the state would be required to provide the funding.

Tarr and others said this change would essentially give local communities veto power over charter schools with little assurance that the state, which has failed to consistently fund the existing charter school reimbursement formula, would provide the necessary funding for the charter school to operate.

Several senators, including Pacheco, said the inclusion of the local control amendment was a key to winning their support for the overall bill, a sign of how tenuous the vote was before debate began.

“I have been out there speaking against the lift to anyone who would listen to me and then I got this bill in front of me,” Sen. Sal DiDomenico said at the end of the debate when he announced that he had decided to support the bill.

By a vote of 5-30, the Senate rejected a Sen. Michael Rodrigues amendment that mirrored the governor’s charter school bill, which was based on the ballot question. Tarr also offered a substitute bill that would have provided additional funding for public education by completely canceling the on-hold expansion of the Boston Convention and Exhibition Center and diverting more future casino gambling revenue to education.

His proposal failed on a voice vote.

“The Senate today approved a phantom cap lift that holds out a false hope for families across the Commonwealth. In reality, it is a carefully crafted moratorium on public charter schools that will prevent tens of thousands of children from having fair and equal access to high quality public schools,” said Marc Kenen, executive director of the Massachusetts Charter Public School Association. “It also endangers existing charter schools by placing unrealistic impediments to their continued operation, and automatic trigger mechanisms to shut them down.”

Earlier in the day, the Race to the Top Coalition, which supports charter school expansion, called the Senate bill “so deeply flawed” that it would require sections to be completely rewritten, which did not happen. The group specifically singled out the Moore amendment as a concern.

Sen. Dan Wolf, a Harwich Democrat who helped write the bill, said he was not giving up on the idea of averting a costly and divisive ballot campaign, though he acknowledged that it will take work to convince many outside the Senate to look at the merits of their legislation, rather than just the perceived flaws.

“Ultimately we do not need a ballot initiative on this. I think we can resolve it in this building and I hope we do that,” Wolf said.

Great Schools Massachusetts, the coalition behind the ballot campaign, said the Senate would bill “does nothing to expand access to high quality public charter schools,” calling the cap lift “basically non-existent” in cities like Boston.

Charter advocates have been particularly concerned about a section of the bill that would allow a city or town to choose to count Horace Mann charter schools and innovation schools, which operate with more local oversight than so-called Commonwealth charters, to count against the cap, eating up cap space.

Proponents of the bill said it makes a number of reforms to how charter schools operate that will provide more transparency and put them on a more level playing field with district schools that charter school critics say educate a disproportionate share of low-income, special education and English language learning students.

The bill would require charter schools to publicly disclose their finances, contracts and board meeting minutes. It requires charter applicants to engage with the local district from which it is seeking to enroll students and establishes an exchange program for teachers in district and charter schools to share best practices.

Charter school teachers would be required to attain certification similar to district school teachers, and charter school teachers would be guaranteed the right to unionize. New charters would also be required to adopt a unified enrollment lottery system with local districts where parents could opt out if they didn’t want to send their children to a charter.