A last-minute measure by California lawmakers to rescue the state’s largest utility from a potential bankruptcy sets up a contentious process whereby its customers could foot the bill for billions in liability costs it faces following the state’s catastrophic 2017 wildfires.

The bill passed Friday night in the final hours of California’s legislative session would give PG&E Corp. a path to pass on to ratepayers legal damages and other costs stemming from fires that swept California’s wine country in October. The blazes killed...