WASHINGTON — President Biden on Saturday signed into law a bipartisan gun bill intended to prevent dangerous people from accessing firearms and increase investments in the nation’s mental health system, ending nearly three decades of gridlock in Washington over how to address gun violence in the United States.
Final passage of the legislation in Congress came one month after a mass shooting at an elementary school in Uvalde, Texas, left 19 children and two teachers dead, a horror that galvanized a bipartisan group of lawmakers to strike a narrow compromise.
“God willing,” Mr. Biden said as he put his pen down on Saturday morning, “it’s going to save a lot of lives.”
The president acknowledged that the legislation fell far short of the sweeping measures he had pushed for, but he said it included some long-sought priorities.
“When it seems impossible to get anything done in Washington, we are doing something consequential,” Mr. Biden said.
For lawmakers, advocates and survivors of gun violence, the law is the culmination of decades of work, building on repeated failed efforts to overcome Republican opposition and overhaul the nation’s gun laws in response to mass shootings across the country. But the law’s enactment came the same week that the Supreme Court struck down a New York law limiting where gun owners could carry a firearm outside the home, citing the Second Amendment.
The passage of the gun bill also provided Mr. Biden with a legislative accomplishment just before he headed to Europe for a pair of summits that will focus primarily on Ukraine. On Saturday, the president also signed a bill extending free meals and other food assistance for children.
The gun legislation will expand the background check system for prospective gun buyers under the age of 21, giving authorities up to 10 business days to examine juvenile and mental health records. It sets aside millions of dollars so states can fund intervention programs, such as mental health and drug courts, and carry out so-called red flag laws that allow authorities to temporarily confiscate guns from any person found by a judge to be too dangerous to possess them.
It pours more federal money into mental health resources in communities and schools across the country, and it sets aside millions for school safety. The legislation also toughens laws against the trafficking of guns and straw purchasing, the practice of buying a gun on behalf of someone barred from purchasing one. And for the first time, it includes serious or recent dating partners in a ban on domestic abusers buying firearms, tightening what is known as the boyfriend loophole.
“I think the whole country was yearning for something real to happen after the terrible tragedies,” Senator Chuck Schumer of New York, the majority leader, said in an interview this past week. Before the Texas shooting, he had spent time in Buffalo, counseling grieving families after a racist attack at a supermarket left 10 Black people dead.
Mr. Biden said he would host both families affected by gun violence and the lawmakers who helped craft the measure at an event at the White House in July, after the Fourth of July recess, and suggested the compromise was a sign that more bipartisan efforts were possible.
“Their message to us was to do something,” Mr. Biden said of the families and survivors of gun violence. “How many times have you heard that? Just do something. For God’s sake, just do something.”
“Well, today, we did,” the president added.
For Mr. Biden and others, the compromise reflected decades of work on gun safety legislation. After 20 children were shot and killed in Newtown, Conn., in 2012, Mr. Biden, the vice president at the time, was tasked by President Barack Obama with drafting a list of executive actions on guns. Mr. Biden also called on lawmakers to expand background checks, but an effort to pass that measure and other gun control provisions failed in the Senate.
After the shootings in Buffalo and Uvalde, Mr. Biden called for reinstating a ban on assault weapons — a restriction he helped pass as a senator that was in effect for a decade before it expired in 2004.
Most of the congressional efforts on guns have been stymied in recent years by Republican opposition, as the party has largely united to block new gun control measures and prevent that legislation from reaching the 60-vote threshold needed for most bills to advance in the Senate. As lawmakers reeled from the images that came out of the Texas shooting, however, party leaders offered their tacit blessing to a small coalition of senators eager to strike a compromise.
But even as Mr. Biden used a rare evening address this month to call on Congress to take sweeping action, such as banning assault weapons and prohibiting the sale of semiautomatic rifles to people under 21, senators focused on measures that could secure enough Republican support to allow for passage in the Senate.
They set aside calls for a federal red flag law, instead agreeing to $750 million in federal grant funding to help states carry out those laws and fund crisis intervention programs. Lawmakers also agreed to allow the enhanced background checks for younger buyers to expire after a decade and let their successors debate extending it, a tactic that led the assault weapons ban to end in 2004.
And while lawmakers and activists have long fought to close the boyfriend loophole, negotiators also agreed that first-time misdemeanor offenders could regain their ability to purchase a firearm after five years as long as they did not commit any other violent offense. (The ban previously applied only to domestic abusers who had lived with, been married to or had a child with the victim.)
“I have to say that this bill doesn’t do everything we would like to do,” Speaker Nancy Pelosi said in a floor speech on Friday. But, she added, “It is a necessary step to honor our solemn duty as lawmakers to protect and defend the American people.”
Ultimately, 15 Senate Republicans supported the measure, including Mitch McConnell of Kentucky, the minority leader. Fourteen House Republicans voted for it. A majority of congressional Republicans, backed by the National Rifle Association, opposed it as too broad, even as Mr. McConnell and Mr. Cornyn acknowledged voters’ desire for action and emphasized their success in narrowing Democratic ambitions.
Many of the supportive Republicans, particularly in the Senate, are not set to face voters this year. But having been flooded with pleas to take action, those who backed the measure appeared largely unmoved by opposition from both gun rights groups and their own colleagues.
“I know that the discussion is overwhelmingly about the politics of it, and frankly, to quote a famous movie, I don’t give a damn,” said Senator Mitt Romney of Utah, recalling that he had supported raising the minimum age to buy an assault weapon before it became clear it was a nonstarter for most Republicans.
“The highest priority, by far, by far is trying to reduce the shootings of children in America, particularly the mass shootings,” he added. “This bill, I believe, will help in that regard. Will it stop them? Of course not, but will it make a difference? I believe so. And for me, that’s enough.”