SANTA BARBARA, Calif. — California will pay the overdue rent of all lower-income tenants affected by the coronavirus pandemic and extend a soon-to-expire moratorium on evictions, despite landlord opposition, through September.

The announcement Friday came after weeks of negotiations in the state legislature. The body is controlled by Democrats, who have been arguing over how best to distribute the bounty of an enormous state budget surplus.

The $5.2 billion program, which will also include payments to landlords, is the largest ever allocated at the state level and will be financed entirely by federal rental-assistance grants issued during the pandemic. Gov. Gavin Newsom (D), who announced the deal with Democratic legislative leaders, has included an additional $2 billion in the package to pay low-income tenants’ overdue utility bills that will be part of the new state budget.

“In terms of the size, scope and scale of the package, if it is not the largest ever it is certainly one of them,” Newsom said after the announcement. In his official statement, he added that despite recent economic gains, the “impacts of COVID-19 continue to disproportionately impact so many low-income Californians, tenants and small landlords alike.”

The package is in part a reflection of just how much money California has after more than a year enduring a public health crisis that has killed almost 63,000 state residents. A state that relies heavily on income tax for revenue benefited from a huge surge in wealth among its most affluent residents over the pandemic year, leaving it with a roughly $76 billion budget surplus.

Newsom, legislators and California’s array of interest groups have been arguing for months about how to best spend the money, with much of it tagged by Newsom and legislators for the recovery of state public education programs, curtailed state employee pay raises and wildfire preparation measures. The federal support will also benefit housing and homeless programs, including the back-rent initiative.

The fiscal bonanza has also proved to be somewhat of a political boon for Newsom, who is facing a recall election this fall, three years into his first four-year term. The effort has been mounted by residents initially unhappy with his immigration policy and then with his handling of the coronavirus crisis. No date has been set yet for the vote.

California, which fully reopened its economy on June 15 after a year of stops and starts, now has among the lowest infection rates in the nation.

The back-rent program has been virtually assured for weeks. California’s rental-assistance programs to date have been available to households making 80 percent of the state’s average median income — about $60,000 a year — with priority given to those bringing in half that amount. All participants must prove they have been financially harmed by the coronavirus outbreak and do not need legal immigration status to qualify.

The details of the new plan outlined Friday call for tenants, who used to receive only a quarter of back-rent assistance, to receive 100 percent of what they owe. Landlords could receive up to 80 percent of their losses under the old plan, but the new deal will reimburse both tenants and landlords 100 percent of past losses without either having to reapply.

“The key thing is to recognize that people in rental housing are still facing financial obstacles, even as our economy reopens,” Assembly Speaker Anthony Rendon (D-Lakewood) said in a statement.

The most recent points of contention have concerned extending the eviction moratorium, now set to expire at the end of the month.

Many landlords have appealed to Newsom to end the protection, given that the economy, which shows signs of a quick recovery, is now open again. But many tenants say they are still unprepared to start paying full rent after a year in which savings have been drained and jobs lost.

While the economy does show signs of accelerating, studies have found that the jobs returning most slowly in the state are at lower income levels. Many of those jobs, mostly in the restaurant, retail and other front-line industries, were lost during the pandemic and are commonly occupied by those most in need of rental assistance.

“We’ve made strides in ending this pandemic, but its impact will continue to reverberate through our economy. Many renters are still out of work,” state Sen. Scott Wiener, a San Francisco Democrat who runs the Senate Housing Committee, said in a statement. “Thousands of families tragically lost someone in their household to COVID-19, which can be both emotionally and financially devastating. We need to ensure our social safety net stays strong, so every Californian can stay stably housed.”

Highlighting a previous announcement regarding the budget and the state’s chronic homelessness problem that has worsened during the pandemic, Newsom emphasized in remarks in San Jose on Friday an $846 million state and federal investment in Project Homekey, an initiative that uses mostly public money to buy properties and convert them into housing for those experiencing homelessness.

California has by far the largest homeless population in the country, estimated at more than 161,000 people.

Newsom has allocated $12 billion in his new budget, which is scheduled to be signed this month, for housing and homelessness programs, including $6 billion for Project Homekey, which he believes is among the most efficient ways to reduce the homeless population because “it makes an actual dent in this crisis not in five or 10 years, but much sooner.”

“We believe this is enough, even though there have been competing arguments nationally about the adequacy of those numbers,” Newsom told The Washington Post. “But the significant challenge will be to get the dollars out in time to make a difference.”