WASHINGTON–Juvenile-record background checks mandated in last year’s sweeping federal gun legislation have prevented more than two-dozen 18-to-21-year-olds from buying guns after turning up problems such as drug abuse and domestic violence, senators who pushed for the new law said. 

The landmark gun bill, in effect since it was signed by President Biden in June, requires juvenile records, including those related to mental health, to be assessed in criminal background checks for prospective gun buyers under the age of 21. The measure has kept at least 27 young people from buying firearms, the lawmakers said, citing numbers and cases provided to them this week by the FBI.

Those barred from gun purchases under the new provisions included an 18-year-old in Nebraska who had been institutionalized for what local law enforcement described as “mental illness and violent outbursts”; another in Arizona who had a long juvenile criminal history including aggravated drug trafficking and threatening with a dangerous weapon; and another who had been arrested months earlier by police, who found marijuana and an unpermitted handgun in his car. 

Another man, 19, was stopped from buying a rifle after his juvenile records revealed he had previously been charged with assaulting a police officer and trying to commit suicide.

Authorities “are discovering pretty quickly some people in deep crisis who shouldn’t have weapons,” said Sen. Chris Murphy (D., Conn.), who negotiated the bill alongside Sen. John Cornyn (R., Texas). The two were among a group of senators who on Thursday traveled to Clarksburg, W.Va., to inspect the FBI’s National Instant Criminal Background Check System, which runs background checks on would-be gun buyers. 

“If we can identify those individuals and hopefully get them some help and keep them from harming themselves and others by getting access to a firearm because of their history of mental illness, we will save lives,” Mr. Cornyn said. “And I believe it’s likely that we already have.”

Federal authorities must now check with local law enforcement and review state records to determine whether any buyer younger than 21 has a juvenile criminal record or mental-health history that would disqualify him or her. Authorities also now have more time to conduct the checks, allotting them up to 10 days to investigate potentially disqualifying juvenile records. 

The lawmakers were joined in West Virginia by Deputy Attorney General Lisa Monaco and FBI Director Christopher Wray.

The new provisions, which make available individuals’ records from before they turned 18, supplement existing background checks of records after that age, which yielded about nine times as many denials for 18-to-21-year-olds since June, the FBI told the lawmakers. 

While the numbers provided to senators represent denials since the law went into effect in June, Mr. Murphy said the juvenile-records check had only been fully implemented throughout the country in recent days.

The firearms legislation—the furthest-reaching in decades—was passed after mass shootings at an elementary school in Uvalde, Texas, and a grocery store in Buffalo, N.Y., by gunmen who had recently turned 18. After a month of debate, it passed by a 65-33 vote in the Senate and by 234-193 in the House, with 14 Republicans joining Democrats in support even as GOP House leadership argued that the law would infringe on the constitutional right to keep and bear arms. 

Among other measures, the law encourages states to enact extreme-risk protection orders, also known as red-flag laws, to allow courts to order guns temporarily removed from people deemed dangerous and imposes criminal penalties on straw purchases, or buying a gun for someone not permitted to, and gun trafficking.

It stopped short of more restrictive measures Democrats had sought, such as raising to 21 the age for purchasing rifles or expanding background checks to cover nearly all gun purchases.

Background checks of juvenile records emerged as a rare area of bipartisan agreement after years of failed efforts to pass significant gun legislation. Some states still prohibit that information from being shared with NICS, leaving an unknown number of people able to buy guns despite juvenile histories that under federal law should have disqualified them. 

Most juvenile records are sealed and many of them are expunged. But lawmakers are looking at ways to motivate states to share them with NICS, if even in a limited way.

“Historically the idea has been, we’re not going to force juveniles, through some indiscretion when they were younger, to carry that around with them the rest of their lives as adults,” Mr. Cornyn said. “But the exception should be when buying a firearm.”