Massachusetts will invest an additional $1.5 billion in K-12 public education over the next seven years after Gov. Charlie Baker signed a funding reform bill, touted by supporters as a generational change, into law Tuesday.

The legislation directs the bulk of new funding toward districts weighed down by cost drivers, aiming to close opportunity gaps that for years have led to disparate educational outcomes across the state.

The law comes four years after a commission warned that Massachusetts was underestimating the actual cost of education by $1 billion annually and more than a year after the last attempt to update the system fell short. Now the focus shifts to a different challenge: following through on the commitment to ramp up funding for schools starting next year.

"If there's one thing I've learned in my 63 years, it's that talent is evenly distributed. What's not evenly distributed is opportunity, and there's a reason why this is the Student Opportunity Act," Baker said at a bill-signing ceremony hosted at English High School. "This legislation is about making sure every kid in the commonwealth of Mass., regardless of where they live or where they're from or where they go to school, has the opportunity to get the education they need to be great."

The law requires the state to spend an additional $1.4 billion — before inflation — on Chapter 70 aid paid to districts, another $90 million on a special education circuit breaker and $10 million for an education innovation trust fund. It does not outline a year-by-year funding schedule, but requires the full investment to be made by fiscal year 2027.

Under the law, the state will also ramp up its reimbursement paid to communities to cover 100 percent of charter school tuition within three years. Charter school funding been a divisive issue over the years.

"While we have much to celebrate today and the signing of this piece of legislation is historic, I'd like to point out that this is just the first step down what I predict is going to be not an easy road," Education Committee Co-chair Rep. Alice Peisch said at Tuesday's ceremony.

Authors believe the updated formula will properly account for four areas of cost underestimated by the current system: employee health care, special education, and high numbers of both low-income students and English language learners.

By properly funding those areas, officials hope to help close persistent gaps that exist between districts.

"Every single child deserves access to an excellent public education," Sen. Jason Lewis, co-chair of the Education Committee, said during the ceremony. "Massachusetts will now have the most progressive school funding formula in the nation, designed to meaningfully address the troubling, very troubling, opportunity and achievement gaps that persist in our public education system."

The path to updating the foundation budget — implemented in 1993 in the wake of a court ruling that Massachusetts had a constitutional duty to provide sufficient education for all students — has been rocky.

A commission in 2015 identified the four major cost drivers and warned about the chronic underinvestment. Since then, lawmakers had been unable to get a compromise bill over the finish line, even as advocates continued pressure and lawsuits were threatened or filed, until this year.

The version they sent Baker last week closely mirrors the bill that emerged from the Joint Education Committee, including language on accountability to ensure the money is spent on student-centric purposes as intended.

American Federation of Teachers Massachusetts President Beth Kontos said the new law is "a true game-changer for low-income students and their communities."

"The Student Opportunity Act will deliver increased state funding to every district, but the greatest increases, rightfully, will go to low-income districts whose students have the greatest needs," Kontos said. "This means that students of all backgrounds will finally be able to enjoy the benefits that their peers in wealthier districts take for granted — everything from smaller classes and additional counselors to up-to-date classroom supplies and more art, music and enrichment."

Lawmakers did not include any new taxes or fees to fund the steady investment increase, so the funding will have to come from existing revenue streams unless a future Legislature revisits the topic.

The education funding will not receive a carveout in the annual consensus revenue process as other transfers such as the MBTA and pension funds do, but Baker said last week schools will "have to be sort of first-in when we make decisions about what the budget looks like."

The full scale of the law may not be felt for several years, but some impacts will be quick: districts must complete their accountability plans for how to use additional funding by April.

"I expect it will be a handful of years, but the good news is there is a real sense of urgency baked into this bill," said Sen. Sonia Chang-Diaz, who served as Education Committee chair last session and has long been an advocate of school funding changes. "The plans from districts are due on April 1, just a few months from now. That will be our first look at how districts intend to use these new resources. Particularly for those higher-poverty communities, significant money is going to start hitting the ground right away, within a year."

After praising passage of the bill, some education advocates turned their attention to higher education as the next target. Massachusetts Teachers Association President Merrie Najimy said that group would renew its focus on a $500 million bill increasing funding for state colleges and university and freezing tuition.

"When that is achieved, Massachusetts really will deserve to be called 'the education state,'" Najimy said in a statement.

Baker signed the bill alongside legislative leaders and Boston Mayor Martin Walsh at Jamaica Plain's English High School, within Chang-Diaz's district.

Chang-Diaz told reporters she did not play a role in selecting where the ceremony would take place, but she said the school is a fitting representation of where the impact will be felt most strongly.

"It's really meaningful, certainly for me personally, but really for many of the advocates who held this bill high for so many years," Chang-Diaz said. "To have it be right here in a district that's a high-impact district at a school that predominantly serves disadvantaged students, low-income students, students of color, English learners — everything this bill is about targeting."

In a common ceremonial step, Baker handed out pens to about a dozen lawmakers right after signing the bill.

When Chang-Diaz received hers, she thrust it straight into the air in celebration.

Said Lewis, "This moment for me ranks right up there with my wedding day and the birth of my two daughters."