LOS ANGELES — Pacific Gas and Electric’s bankruptcy filing on Tuesday, to deal with billions of dollars in wildfire liability, set off a scramble by the company, investors and elected leaders in California to protect themselves and influence what happens next.

The corporate reorganization is shaping up to be one of the most complicated and difficult in recent years. In addition to traditional legal tussles between the company and its creditors and suppliers, the bankruptcy court will contend with demands by California officials and victims to force PG&E to pay damage claims estimated at tens of billions of dollars for wildfires started by its equipment. State leaders and residents are also likely to seek to thwart any effort by the utility to raise electricity rates.

Coming up with a bankruptcy plan for PG&E, which is California’s largest utility and serves 16 million people, will amount to solving an intricate puzzle. Proposals to raise rates to pay creditors will inflame residents and lawmakers. And seeking to reduce what the utility pays for solar power could hurt renewable-energy companies and jeopardize California’s climate-change goals.

“This is a real mess,” said Dan Reicher, an assistant energy secretary in the Clinton administration. “It comes down to lots of needs: Take care of the fire victims, keep the lights on, ensure progress on climate change and protect ratepayers. That’s at least a partial list.”

Even before the company made its filing in United States Bankruptcy Court in San Francisco, various groups were sniping at one another. Shareholders accused the company of rushing into bankruptcy. And consumer groups said the State Legislature was bailing out utilities by letting PG&E and other companies raise electricity rates, already among the highest in the country, to pay for some wildfire liabilities.

PG&E said this month that bankruptcy was its “only viable option.” In its filing, the company said it had $51.7 billion in debt and $71.4 billion in assets as of Sept. 30. Its liabilities will most likely be revised up significantly as state investigators establish the cause of deadly wildfires in the last two months of 2018.

This is the utility’s second bankruptcy in less than 20 years. It sought bankruptcy protection in 2001 after a botched state deregulation of the electricity industry.

Investors and state officials tried to persuade the company’s board to change its bankruptcy plans in recent days by offering alternatives. Some of them hoped a state finding last week that PG&E did not cause the Tubbs Fire, which tore through Sonoma County in 2017 and was the second-worst fire in California history, had reduced the utility’s liabilities enough to make bankruptcy unnecessary.

But PG&E still faces liability claims for 17 of 21 major wildfires in 2017. And its equipment is under investigation in several 2018 wildfires, including the Camp Fire, which killed at least 86 people and destroyed thousands of properties.

By the start of this week, many investors and state officials appeared resigned to the company’s filing. The California Public Utilities Commission held an emergency meeting Monday to approve PG&E’s plan to borrow $5.5 billion to finance itself over the next two years while it is in bankruptcy.

California’s lawmakers thought they had taken care of PG&E’s wildfire liabilities last year when they passed legislation that allows the utility to raise rates to pay damage claims from the 2017 wildfires. After the November fires, lawmakers were considering expanding that legislation to cover 2018.

But they abandoned that proposal two weeks ago when the utility announced that it would seek bankruptcy protection.

Assemblyman Chris Holden, chairman of the Utilities and Energy Committee, said Tuesday that he was drafting a bill to direct the California Public Utilities Commission to press PG&E to fully compensate wildfire victims. The legislation would also direct the commission to resist efforts by the utility to raise electricity rates. Mr. Holden, a Democrat from Pasadena, said he hoped it would pass before the company submitted its restructuring plan in court.

Assemblyman Marc Levine, a Democrat from Northern California, said the Legislature ought to revise or revoke parts of the 2018 law, a step that could increase losses for PG&E’s creditors and suppliers.

“In the longer run, the Legislature and the administration have an obligation to ensure that the company’s ratepayers and fire victims are prioritized over shareholders,” Mr. Levine said.

Lawmakers who have long been critical of PG&E, including State Senator Jerry Hill, a Democrat from San Francisco, are pushing for even farther-reaching changes. Some of them want PG&E’s gas and electric divisions separated or would like to break up the utility into smaller businesses with a smaller geographic footprint.