RICHMOND — It may have looked like Richmond was burning this week as it did in 1865, but legislators worked through chaos and scandal to unveil a $1 billion bipartisan agreement Friday on tax relief.

Lawmakers hashed out differences on state finances that had seemed almost insurmountable, all while national attention was focused on one revelation after another about the three top Democrats in the executive branch.

Gov. Ralph Northam (D) has been in near-seclusion as he ponders calls for his resignation over a racist photo on his medical school yearbook page and the admission that he wore blackface for a dance contest in 1984.

Attorney General Mark R. Herring (D) admitted to wearing blackface to imitate a rapper at a college party in 1980. And Lt. Gov. Justin Fairfax (D) has denied allegations that he sexually assaulted a woman in 2004. On Friday, a second woman said she was sexually assaulted by Fairfax while they were undergraduate students at Duke University. Fairfax denied that accusation, too.

“I think one of the unfortunate things with all of this background noise that is going on — and [they are] very serious issues — is that the accomplishment of the legislature of both Republicans and Democrats is kind of being drowned out, which is really unfortunate,” Senate Majority Leader Thomas K. Norment Jr. (R-James City) said Friday.

Norment himself has been touched by scandal with the disclosure that he was an editor at the Virginia Military Institute yearbook in 1968 when it published racist images and derogatory racial terms. He said he had nothing to do with those items.

The tax agreement is a significant win for Republicans who control both chambers of the General Assembly and are eager to show themselves as moderate and capable in a high-stakes election year.

“Under Republican leadership, the House and Senate have agreed to the most significant tax relief package in the Commonwealth in at least 15 years,” House Speaker Kirk Cox (R-Colonial Heights) said in a news release announcing the deal.

All 140 seats in the legislature are on the ballot this fall. Democrats have had momentum on their side, as well as a favorable ruling in a redistricting case, but are watching their advantage slip away with every new scandal.

But the agreement also allowed Democrats to claim credit for shifting the tax package in a way that provides more relief to low-income families, which had been a priority.

“We wanted tax relief for people who weren’t getting it in the federal [tax cut] plan and that’s what we got,” said Del. Schuyler T. VanValkenburg (D-Henrico).

The deal includes a sharp increase in the standard deduction for people filing state tax returns — for individuals, to $4,500 from the current $3,000; and for married couples, to $9,000 from $6,000.

In addition, taxpayers will get a one-time refund in October — just before election season — of up to $110 for individuals and $220 for married couples.

State and local taxes will continue to be deductible at current rates instead of being capped, as they are in the federal plan. And several business tax breaks bring the total value of the package to at least $976 million.

All sides surrendered some priorities, and Democrats insisted they did not feel that they were dealing from a position of weakness because of Northam’s precarious status. Northam’s finance secretary, Aubrey Layne, worked closely with Republican leaders in putting the plan together.

The pact solves a stalemate that has prevented the state from being able to process this year’s Virginia income tax returns, reconciling state practice with federal tax policy.

The 2017 Tax Cuts and Jobs Act, passed by the GOP-led Congress and signed by President Trump, left Virginia and other states out of sync. Many people who used to itemize their federal taxes switched to a more generous standard deduction created by Congress.

Under Virginia law, those filers also had to switch to the state’s relatively small standard deduction. That meant many Virginians would be paying more in state income tax, leading to roughly $1 billion in anticipated new revenue.

Northam had wanted to use some of that new money for a tax rebate for low-income working families, but Republicans in both chambers nixed that idea early on. Instead, the House GOP had wanted to let Virginians decouple from federal policy and continue itemizing state returns even if they used the federal standard deduction.

Del. Vivian E. Watts (D-Fairfax) argued repeatedly on the House floor that such an approach, proposed by Del. Tim Hugo (R-Fairfax), would primarily benefit people in higher income brackets.

Senate Republicans had proposed simply increasing the standard deductions, which Democrats preferred because about half of the tax relief would flow to those who earn below $50,000 a year. That’s the model that prevailed.

The tax plan does not allow for the generous and far-reaching spending increases proposed by Northam, but there is agreement for pay raises for teachers and a few other goodies, including modest increases for housing, school counselors and environmental issues.

Both chambers still have to put the package through parliamentary approvals, and some budget details will be ironed out over the next few days. But there appears to be enough support for an emergency clause that will allow the deal to go into effect as soon as the governor signs it.

Still, the amount of tax relief for low-income Virginians left some progressives unhappy. Noting that much of the political scandal of the past week has focused on matters of race, Michael Cassidy, of the left-leaning Commonwealth Institute for Fiscal Analysis, complained that the General Assembly had missed a chance to address economic disparity among minorities.

Sen. J. Chapman “Chap” Petersen (D-Fairfax City) took an overall positive view, although he said he would have preferred more tax relief for low-income families. But he said that amid the scandals, Democrats were not in a position to play hardball.

“We can be obstructionists, or we can say, ‘This is not the week to be obstructionists. This is actually the week to get something done,’ ” Petersen said. “I’m happy with it. I think it makes sense.”