Pacific Gas & Electric and lawyers for victims of California wildfires that killed dozens of people and destroyed tens of thousands of homes and businesses, including the 2017 Tubbs fire that ravaged Santa Rosa, agreed Friday to a multibillion- dollar legal settlement.

The victims would not receive all of the $13.5 billion that is being made available under the agreement. Some of it would go toward paying the claims of some government agencies, and the victims’ lawyers would receive a portion.

The accord, which follows months of tense negotiations, is a big step forward for PG&E, whose response to wildfires has often faltered. For victims, the money would help them rebuild homes and lives after months of uncertainty, though many would most likely get a lot less than they had hoped for or need.

And a settlement would significantly increase the likelihood that PG&E will emerge from bankruptcy before a crucial deadline in June. The company filed for bankruptcy protection in January, saying it faced an estimated $30 billion in wildfire claims.

“We’ve turned a corner,” said Patrick McCallum, a lobbyist who runs the wildfire victims group Up From the Ashes. He and his wife, Sonoma State University President Judy Sakaki, lost their Fountaingrove home in the Tubbs fire in 2017. “We’re close. Finally there’s a solution for wildfire victims.”

Because not all wildfire victims have filed claims yet, it is unclear at this point how much of the settlement will go toward those affected by the 2017 North Bay fires, said Roy Miller, a Santa Rosa lawyer whose firm is representing thousands of wildfire victims with property losses. Miller said the breakdown of the $13.5 billion will likely be determined over the winter months, into early spring.

Miller, who lost his Wikiup home in the Tubbs fire, said he was “ecstatic” by the settlement, calling the deal “fair.”

“I’m just happy that we’re going to be able to close this chapter because it’s time for Santa Rosa to get rebuilding and for all of us to be able to move on,” he said.

The settlement, which requires approval by U.S. Bankruptcy Court, follows accords that PG&E announced with insurance companies and some government agencies. A court hearing is scheduled for Dec. 20. Miller was confident that the settlement will be approved by a judge and the California Public Utilities Commission.

To receive payments, wildfire victims must file claims by Dec. 31, a deadline that was extended after tens of thousands of victims failed to submit claims and some said they were not even aware of the process.

Miller said he hoped wildfire victims would receive their payments within a year.

Even with the settlement, the future of the utility’s operations remains uncertain. The devastating wildfires in 2017 and 2018, including the Camp fire, which destroyed the Butte County town of Paradise, enraged many residents and elected officials, including Gov. Gavin Newsom and Mayor Sam Liccardo of San Jose. Those leaders, including the mayors of Petaluma, Sonoma and Cotati, have proposed making PG&E a public utility, turning it into a cooperative owned by its customers or selling it to an entity such as Warren Buffett’s Berkshire Hathaway, which owns several large energy companies.

“There have been many calls for PG&E to change in recent years,” the company’s chief executive, Bill Johnson, said in a statement. “PG&E’s leadership team has heard those calls for change, and we realize we need to do even more to be a different company now and in the future.”

The breadth of the settlement will help PG&E move on from one of its biggest legal challenges.

The accord not only settles claims arising from the wildfires of 2018 and 2017 but also encompasses those from the Butte fire in 2015 and the Ghost Ship fire in 2016 in Oakland. PG&E was one of several organizations sued by the families of victims of the Ghost Ship fire, which killed 36  people during a party in a warehouse with a long record of safety violations.

Cal Fire had cleared PG&E of responsibility for the Tubbs fire, but a California Superior Court judge scheduled a January trial to determine whether PG&E’s equipment caused it. The settlement could eliminate the need for that trial.

Miller hailed the inclusion of the Tubbs fire victims, saying they represent about 90% of his case docket.

“The Tubbs fire was not going to be left behind,” Miller said. “Obviously, my home and thousands of other people’s in Santa Rosa were affected by Tubbs. The idea of Tubbs being treated less than equal was a red line for me.”

Along with the destruction from wildfires caused by PG&E’s equipment, the utility has faced growing criticism over its failure to inspect and maintain its transmission network.

Many Californians have also expressed anger at how the company shut off power to millions of people during periods of high winds and dry conditions to prevent fires.

In October, four PG&E shut-offs affected customers in Sonoma County, with the largest such outage affecting about 93,000  homes and businesses as winds roared during the first weekend of the Kincade fire.

A report released last week by the California Public Utilities Commission identified a 100-year-old transmission tower as the cause of the Camp fire.

It also revealed significant shortcomings in PG&E’s inspections of its power lines, a major cause of wildfires in the state.

In recent bankruptcy negotiations, representatives of Newsom have pressed PG&E to compensate wildfire victims sufficiently, treat workers fairly and maintain its commitment to clean energy. The governor has said the utility that emerges from bankruptcy must make safety a priority.

In a statement, lawyers for the victims said a trust would be set up to pay the victims’ claims, funded with a mix of “cash, equity and other consideration.” The equity is expected to be stock in the PG&E that emerges from bankruptcy. But the stock could lose some of its value if PG&E faces new financial challenges, including from wildfires or other disasters caused by its equipment, potentially shortchanging victims.

PG&E has already agreed to pay holders of insurance claims $11 billion in cash.

PG&E’s stock surged this week as investors became more upbeat about the prospects of a deal with the wildfire victims, but closed down 1.3% on Friday.

The company had originally offered to pay individual victims up to $8.4 billion, but increased its offer last month to try to win over the victims. Lawyers for the victims estimated in July that claims against PG&E totaled $54 billion for the fires of 2017 and 2018.

While Miller said he wanted to do all he could to “make people as whole as possible” by getting a large settlement for his clients, he also knew that if the number was too high, PG&E wouldn’t receive the financing it needed to pay out the settlement.

“PG&E is in the process of transforming itself,” Miller said. “We had to make sure there was some money available for them to revamp their grid and making sure that this isn’t a yearly event of fires ravaging our cities because that’s not sustainable.”

PG&E must emerge from bankruptcy by June in order to draw from a wildfire fund that California set up this year. The fund will help the state’s three large investor-owned utilities pay future wildfire claims if they meet certain conditions like improving safety practices.

On Thursday, a federal judge overseeing PG&E’s probation stemming from a 2010 gas explosion that killed eight people in San Bruno asked the utility to provide more information about equipment and inspection failures before the Camp fire.

Depending on the company’s answers, the judge, William Alsup, could initiate new disciplinary hearings or impose additional penalties against the company.

Press Democrat Staff Writer Chantelle Lee contributed to this report.