State Sen. Scott Wiener (D-San Francisco) addresses the California Senate, which passed the toughest net neutrality law in the country. Wiener sponsored the bill. (Rich Pedroncelli/AP)

California lawmakers rallied enough votes Friday to pass the nation’s toughest net neutrality law to prevent Internet providers from favoring certain websites, setting up a fight with federal regulators who voted last year to erase such rules.

If Gov. Jerry Brown (D) signs the law in the coming weeks, California will become the powerhouse in a growing group of states at odds with the Federal Communications Commission in a clash that could end up before the Supreme Court.

The legislation, which was the subject of intense lobbying by the broadband industry, would prevent Internet providers from blocking, slowing or favoring certain websites. It would bar providers from collecting new fees from apps and sites as a condition of reaching Internet users. And it would make it illegal for carriers to exempt apps from consumers’ monthly data caps if doing so could harm competing start-ups and small businesses in “abusive” ways.

“It would have huge implications for the U.S., because California is so central to all things Net and is the world’s eighth-largest economy,” said Carl Tobias, a law professor at the University of Richmond. A lawsuit targeting the bill could eventually find its way to the Supreme Court, Tobias added. The court is already weighing whether to hear an unrelated lawsuit on net neutrality.

California similarly took the regulatory lead in passing a sweeping online privacy law in June — something the federal government has not been able to do.

More than 20 states are suing the FCC to overturn the agency’s decision on net neutrality. Nearly three dozen states have introduced bills to replace the defunct regulations, and three states have already approved them.

California could become the fourth state to approve net neutrality regulations if Brown signs the bill. He has not taken a public stance on it, according to policy analysts, but the bill passed both Democrat-dominated state chambers by wide margins.

“This is basic consumer protections, protecting small and midsize businesses, protecting activists and labor unions and anyone else who uses the Internet,” said Democratic state Sen. Scott Wiener, the bill’s sponsor, who represents the San Francisco area.

patchwork of state laws could make compliance more difficult for Internet providers and lead to a legal challenge focusing on the power of the federal government to preempt state laws. In some of its provisions, the California bill goes further than the national rules that the FCC repealed, taking an expansive view of the broadband industry’s public obligations.

Industry groups have said a single, uniform law written by Congress would be far more effective at guaranteeing net neutrality protections for Internet users. AT&T, which pushed hard against the California bill through its local lobbyists, has called for a national “Internet Bill of Rights” that would cover Internet providers and online platforms alike, such as Google and Facebook.

“The internet must be governed by a single, uniform and consistent national policy framework, not state-by-state piecemeal approaches. Governor Brown should use his veto pen on this legislation, and Congress should step in to legislate and provide consumer protections that will resolve this issue once and for all,” said a statement from Jonathan Spalter, chief executive of USTelecom, an industry trade group.

FCC Chairman Ajit Pai was a longtime critic of the federal net neutrality rules. Approved under Democratic Chairman Tom Wheeler in 2015, the regulations barred providers from blocking or slowing Internet content, and paved the way for tough new digital privacy protections for consumers.

The limitations provoked a loud outcry from Internet providers such as Verizon and Comcast, which said the rules would add unnecessary costs to their businesses and prevent them from investing in upgrades to their networks. Consumer groups, however, argued that the rules were vital to protect users at a time when Internet providers are focused on buying up media companies and establishing Facebook-like businesses that mine user data for advertising purposes.

After Pai was appointed by President Trump last year to head the FCC, one of his first acts was a plan to roll back the Obama-era regulations. He sided with the broadband industry, adding that the net neutrality rules were an example of unlawful government overreach.

Pai’s critics have launched a multi-pronged effort to reverse that move, filing lawsuits in federal court, demanding a congressional vote to overrule the FCC and pushing for state legislation — such as California’s.

The final bill passage came after the state Assembly voted 61 to 18 to approve the measure Thursday, followed by a 27-to-12 vote Friday by the Senate.

Consumer groups such as the Electronic Frontier Foundation and a number of smaller tech companies including Etsy, Reddit and Sonos lined up in favor of the bill. Broadband-industry-backed groups such as CALinnovates and the Congress of California Seniors argued against it.

Net neutrality has been a major policy issue in particular for smaller tech companies, which say they stand to be disadvantaged by special commercial partnerships that Internet providers could seek with large, established firms such as Google, Facebook and Netflix.

Without strong rules, say companies such as Eventbrite and ­Vimeo, Internet providers could engage in anticompetitive behavior that harms smaller online companies, reducing consumer choices.

The fight in California grew so intense that some state residents reported receiving robocalls warning that the legislation could lead to an increase in their Internet bills. In June, the measure appeared to hit a sudden snag when a key Assembly committee voted to strip out its toughest language — provisions that were restored two weeks later amid pressure from activists.

Net neutrality activists cited their legislative victory Friday as a validation of their congressional strategy: to pressure vulnerable federal lawmakers who are running for reelection this year to endorse stronger net neutrality rules at a national level.

“Internet users are still royally pissed off about the FCC’s repeal,” said Evan Greer, deputy director of Fight for the Future, a consumer advocacy group. “They’re still paying attention. And they’re not going to let their elected officials get away with it if they sell out their constituents by siding with big telecom companies.”