Congress on Thursday rapidly cleared a $2.1 billion emergency spending package that will avert a Capitol Police funding crisis sparked by the Jan. 6 riot and also provide urgent funds to evacuate and resettle Afghans who aided U.S. forces during the 20-year war in their homeland.

Leaders of the Capitol Police and National Guard units warned of imminent cuts if Congress did not act to backfill expenditures made in the wake of the Capitol attack, and lawmakers responded swiftly by congressional standards, delivering a bipartisan package that advanced to the Senate floor with relatively little drama.

The Senate voted 98-0, and the House followed suit hours later, 416-11. The White House released a statement Thursday supporting the bill, indicating President Biden will sign it.

The accord was reached after several weeks of wrangling between the parties, and the top Senate appropriators, Sens. Patrick J. Leahy (D-Vt.) and Richard C. Shelby (R-Ala.), clinched a deal Tuesday just as a panel of four police officers testified about the grievous trauma they endured before a special House committee investigating the Jan. 6 attack.

The bill provides nearly $71 million to the Capitol Police, with much of that funding going to cover overtime costs. Millions more will go to beef up intelligence capacity, improve civil disturbance training, provide more protective details for lawmakers, supplement the force’s equipment and offer trauma support to officers.

More than a half-billion dollars, $521 million, will cover the costs incurred by National Guard units who were called to the Capitol after the riot and stayed for more than five months, while another $300 million is earmarked to harden doors and windows on the Capitol campus and install new camera systems.

The bill would also grant $42 million to cover the costs of responding to the pandemic on Capitol Hill, including reimbursements for overtime, protective equipment, cleaning costs and telework equipment.

The majority of the bill’s total spending, however, is devoted to closing out the United States’ two-decade entanglement in Afghanistan. While Biden has vowed to withdraw all U.S. troops by the end of August, save for a small garrison in Kabul, the Pentagon and State Department have scrambled to evacuate Afghans who served as interpreters or otherwise aided Western forces fighting the Taliban.

A half-billion dollars in new Pentagon funding would fund emergency transportation and housing for those Afghans and their families, as well as another $600 million in State Department funding. The bill makes available an additional 8,000 “special immigrant” visas beyond the 26,500 already authorized, while also easing some of the eligibility requirements for those visas.

Both top Senate leaders praised the deal ahead of the vote, with Majority Leader Charles E. Schumer (D-N.Y.) on Thursday thanking Leahy and Shelby and urging others senators to support the bill.

“We owe the Capitol Police, we owe the National Guard our deepest gratitude, but we owe them . . . more than just that,” he said Thursday. “We owe them the resources they need to do a very difficult job and to do it well.”

Senate Minority Leader Mitch McConnell (R-Ky.) on Wednesday also called for the deal’s passage, saying lawmakers “owe a real debt” to the troops and law enforcement officers who secured the Capitol.

“And,” he added, “we intend to keep our nation’s promises to brave Afghans who have taken great risks to help America and our partners fight the terrorists.”

Still, the bill did not go quite as far as some wished. Democratic appropriators initially requested a $3.7 billion package that would have provided much more for permanent security upgrades on Capitol Hill and also supplemented Justice Department funding to support the prosecutions of those charged in the riot.

But they all, including House Appropriations Committee Chairwoman Rosa L. DeLauro (D-Conn.), set aside their objections Thursday.

“This bill is not perfect, but time is running short, and the immediate needs are dire,” DeLauro said. “The men and women of the Capitol Police protected us. They said yes. Now we must protect them. We must say yes.”