State laws that allow the removal of guns from people who present a threat to themselves or others may play a role in preventing mass shootings, according to a new study, a finding that could buttress support for “red flag” legislation being debated in Congress.

The study by a team at the nonpartisan Violence Prevention Research Program at the University of California at Davis identified more than 20 cases in which California’s red-flag law was used in an effort to prevent a mass shooting.

None of the threatened shootings in those cases took place, according to the study, which will be published this week in the Annals of Internal Medicine.

Researchers could not definitively state that California’s red-flag law was responsible, noting that it was impossible to know whether threats would have been carried out.

But the cases “suggest that this urgent, individualized intervention can play a role in efforts to prevent mass shootings, in health care settings and elsewhere,” the researchers said.

Jeffrey Swanson, a professor at the Duke University School of Medicine who studies gun violence, said the research was an advance in the understanding of the effect of red-flag laws.

“This amounts to pretty powerful anecdotal evidence,” Swanson said. “Here are some real cases of real people that made a real threat, and they were identified through the process of this gun violence restraining order.”

Swanson echoed the authors’ cautions against drawing the conclusion that the orders had stopped acts of violence, saying more study of gun-removal laws was needed in additional states. “This is an area where we need more research,” he said.

Red-flag laws have been passed in 17 states and the District of Columbia, according to the Giffords Law Center to Prevent Gun Violence.

The findings arrive amid a national debate on the most effective — and politically feasible — measures to avert acts of large-scale gun violence. Back-to-back shootings earlier this month left dozens dead in El Paso and Dayton, Ohio.

The shootings prompted an outcry for action from Congress, where lawmakers have for years been unable to agree on the need for tougher gun-control measures. Red-flag laws, which are intended only for people deemed dangerous and are not supposed to affect most gun owners, have gained traction as a possible bipartisan solution.

A Washington Post-ABC News poll last year found that more than 8 in 10 Americans supported allowing police to take guns from people if a judge determines they are a danger to themselves or others.

Sens. Lindsey O. Graham (R-S.C.) and Richard Blumenthal (D-Conn.) are seeking to advance legislation that would create a federal grant program that offers funding for states to enact red-flag programs. President Trump has expressed support for the laws, although it is unclear how hard he would push for them.

Law enforcement officials and academic researchers have found that red-flag laws are primarily used in cases of people threatening suicide, not murder. A study published last year found that gun-confiscation measures were associated with a 13.7 percent drop in the gun-suicide rate in Connecticut and a 7.5 percent reduction in Indiana.

Less evidence exists concerning the impact on potential homicides, including mass shootings. Garen Wintemute, director of the Violence Prevention Research Program and lead author of the new study, said his team at first undertook a broad assessment of the impact of California’s law, which took effect in 2016.

But in the spring, he said, he decided to publish an early set of findings after seeing that the law had been invoked with surprising frequency to try to avert mass shootings. That choice was made before the recent spate of mass shootings refocused national attention on red-flag laws, he said.

Of 159 cases for which U.C.-Davis researchers have so far obtained records, there were 21 in which the subject was suspected of posing a risk of a mass shooting and a protective order was sought. (In some of those cases, the individual was attempting to purchase a gun but had not yet obtained it because of California’s 10-day waiting period.)

The law was invoked in a total of 414 cases in California from 2016 through 2018, according to the study.

Most of the subjects in those cases were white men, with a mean age of 35. They included a 33-year-old armed security service worker who quit his job and threatened to shoot a former co-worker and a 21-year-old who posted threatening statements on Instagram about his former high school.

Adelyn Allchin, senior director of public health and policy at the Coalition to Stop Gun Violence, said the study lends credibility to arguments for widespread adoption of red-flag laws, even without an ironclad finding that California’s legislation averted shootings.

“It’s really promising to see these results come out,” Allchin said. “I think there’s some good evidence here that these laws are preventing acts of mass violence.”