WASHINGTON — Congress gave final approval on Friday to a bipartisan compromise intended to stop dangerous people from accessing firearms, ending nearly three decades of congressional inaction over how to counter gun violence and toughen the nation’s gun laws.
The House approved the measure 234 to 193 one month to the day after a gunman stormed into an elementary school in Uvalde, Texas, and used a semiautomatic rifle to kill 19 children and two teachers, sparking outrage across the country and a flurry of negotiations on Capitol Hill. The measure now heads to President Biden, who is expected to sign it.
“This bipartisan legislation will help protect Americans,” he said in a statement on Thursday evening. “Kids in schools and communities will be safer because of it.”
Galvanized by the horror of the Texas shooting, as well as a racist attack at a Buffalo supermarket that left 10 Black people dead in May, lawmakers struck a deal that fell far short of the sweeping gun control measures Democrats have long demanded but was more expansive than the steps that Republicans have been willing to consider in the past given their hostility to any step that might curb access to guns.
The legislation will enhance background checks for potential gun buyers under the age of 21, requiring for the first time that authorities have time to examine juvenile records, including mental health records beginning at age 16.
It provides millions of dollars for states to implement so-called red flag laws that allow officials to temporarily confiscate guns from people deemed in court to be too dangerous to own them, and other intervention programs. And it strengthens laws against straw purchasing and trafficking of guns.
In addition, the measure pours more federal money into shoring up mental health programs across the country, and toughening security in schools. And the bill tightens a federal ban on domestic abusers buying firearms, including recent or current serious dating partners, to close what has come to be called the boyfriend loophole.
“Our success today will never be the end of this fight, but this is a beginning,” said Representative Lucy McBath, Democrat of Georgia, whose son was shot and killed by a white man at a gas station in 2012. She added, “This gives us hope. This gives America hope. This gives our communities the sorely needed hope that we have been crying out for, for years and years and years.”
Ms. McBath later grew emotional on the House floor, wiping away tears as she embraced her Democratic colleagues and celebrated the legislation’s passage. Applause broke out in the chamber as it became clear the bill had secured a majority of support.
Final passage of the measure came a day after 15 Republican senators joined Democrats in breaking a G.O.P. filibuster to push the measure through the Senate, clearing a hurdle that had proved insurmountable for most past efforts to update gun laws after other horrific mass shootings.
The House passed the measure with a similarly low margin of Republican support, as top G.O.P. leaders urged their members to oppose the measure as a threat to the Second Amendment. Just 14 Republicans voted in favor of the legislation, joining all the Democrats. Five of those Republicans are retiring, and one, Representative Tom Rice of South Carolina, recently lost his primary to a Trump-backed challenger.
“As a mother and a constitutional conservative, I’m proud to support this sensible bill that will protect our children and limit violence without infringing on law-abiding citizens’ Second Amendment rights,” said Representative Liz Cheney of Wyoming, who has been largely ostracized from her party over her role on the House select committee investigating the Jan. 6 riot. “Nothing in the bill restricts the rights of responsible gun owners. Period.”
But the majority of Republicans remained unmoved by efforts by their colleagues to emphasize the narrow scope of the firearm provisions and the investment in mental health resources.
“Today, they’re coming after our Second Amendment liberties, and who knows what it’ll be tomorrow,” Representative Jim Jordan of Ohio, the top Republican on the Judiciary Committee, said of Democrats.
Representative Rodney Davis, Republican of Illinois, recalled a shooting at a baseball field in Virginia that left Representative Steve Scalise of Louisiana, the Republican whip, severely wounded and how he wished he had a firearm with him for protection that day.
“The actions on the field that day solidified my support for the Second Amendment,” Mr. Davis said.
Final approval of the measure came after the Supreme Court struck down a New York state law that restricted where gun owners could bring a firearm outside the home, a decision that cast a pall for some Democrats who were elated about the gun bill’s success after decades of congressional failure on the issue.
“I was really in an exalted state about what happened in the United States Senate yesterday — counterpoint to the dangerous decision of this Trumpian Supreme Court that they made yesterday,” said Speaker Nancy Pelosi of California, speaking at her weekly news conference on Friday.
Even as some Democrats complained that the measure fell short of their ambitions to ban the sale of high capacity magazines or raise the purchasing age for assault weapons, she encouraged lawmakers to back the measure as a substantial step forward toward those goals. Wearing an orange pantsuit — the color of gun reform activists, which was visible across the Democratic side of the chamber — Ms. Pelosi personally gaveled the vote shut.
“As I say to members all the time with legislation, do not judge it for what isn’t in it, but respect it for what it is,” Ms. Pelosi added. “There is much to be respected in this legislation.”
The compromise was struck by a small group of Senate Republicans and Democrats, including Senators Christopher S. Murphy of Connecticut and Kyrsten Sinema of Arizona, both Democrats, and John Cornyn of Texas and Thom Tillis of North Carolina, both Republicans.