SACRAMENTO — California has just kicked for-profit management companies out of the charter school business.

A bill signed into law Friday afternoon prohibits companies from managing or running the state’s taxpayer-funded, independently run charter schools. Assembly Bill 406 was inspired, in part, by an investigation by this news organization into allegations of profiteering at the expense of children’s educations.

The 2016 news investigation focused on K12 Inc., a for-profit company based in Virginia and traded on Wall Street that manages publicly funded charter schools in California and other states. The K12-run network, California Virtual Academies, with an enrollment of roughly 15,000, graduated fewer than half of its high school students, and some teachers said they were pressured to inflate grades and enrollment records.

The bill by Assemblyman Kevin McCarty, D-Sacramento, was the latest of several attempts to crack down on the industry, including schools such as California Virtual Academies that are technically nonprofits but are controlled by corporate interests. A rare alliance of teachers’ unions and the state’s charter school trade association — which originally opposed the legislation but eventually supported it — pushed it across the finish line.

“With support from (the California Charter Schools Association), the Governor sent a clear message today: There’s no room for profits in public education,” said Jed Wallace, the association’s president and CEO. “Charter schools are an integral part of California’s public school system. We are thrilled that our state has embraced a thriving charter school sector that is public, free, open to all, and 100 percent operated by non-profit organizations.”

California currently has about 35 such charter schools, according to McCarty’s office. In 2016 K12 settled a lawsuit with the state for $168.5 million over claims that it manipulated attendance records and other measures of student success.

Start your day with the news you need from the Bay Area and beyond.

Sign up for our Morning Report weekday newsletter.

A spokesman for K12 Inc. was not immediately available for comment.

The law takes effect July 1. The relatively small number of schools run or managed by for-profit companies will be allowed to remain open as long as they show they have nonprofit management by the time their charter is next up to be renewed.