WASHINGTON — Congressional Republicans, under intense pressure to respond to this weekend’s massacres, are coalescing around legislation to help law enforcement take guns from those who pose an imminent danger — a measure that, if signed into law, would be the most significant gun control legislation enacted in 20 years.

John Barrasso, John Thune are posing for a picture: Senator John Thune, Republican of South Dakota, said he was “confident Congress will be able to find common ground on the so-called red flag issue.”© Gabriella Demczuk for The New York Times Senator John Thune, Republican of South Dakota, said he was “confident Congress will be able to find common ground on the so-called red flag issue.”Such “red flag” laws might not be as momentous — or controversial — as the now-expired assault weapons ban or the instant background check system, both of which were enacted in 1994 as part of President Bill Clinton’s sprawling crime bill. The House, under Democratic control, passed far more ambitious bills in February that would require background checks for all gun purchasers, including those on the internet or at gun shows, and extend waiting limits for would-be gun buyers flagged by the instant check system.

Sign Up For the Morning Briefing Newsletter

But those bills have run into a blockade that Senator Mitch McConnell, the majority leader, has erected for House bills he opposes.

Now, after back-to-back shootings this weekend left 31 people dead in El Paso and Dayton, Ohio, Republicans who have long resisted gun restrictions appear rattled. In Ohio, Gov. Mike DeWine was shouted down on Sunday by mourners in Dayton demanding that he “do something.” On Tuesday, he urged his fellow Republicans in the state legislature to pass measures establishing red flag powers and expanding background checks.

“They were absolutely right,” Mr. DeWine said Tuesday morning at a news conference. “We must do something, and that is exactly what we are going to do.”

Representative Michael R. Turner, a Republican whose district includes Dayton, went further.

“I will support legislation that prevents the sale of military-style weapons to civilians, a magazine limit and red flag legislation,” he said in a statement Tuesday. “The carnage these military-style weapons are able to produce when available to the wrong people is intolerable.”

But in the Senate, where a background checks bill failed in 2013 after 26 children and staff members were gunned down at Sandy Hook Elementary School in Newtown, Conn., red flag laws may be the only gun-related measure that could squeeze through. President Trump endorsed the idea on Monday in a speech from the White House, giving skittish Republicans cover to embrace it.

Senator John Thune of South Dakota, the No. 2 Republican, told his hometown newspaper, The Argus Leader, that he was “confident Congress will be able to find common ground on the so-called red flag issue.” Senator Lindsey Graham, Republican of South Carolina, has already proposed legislation that would offer federal grants to states to help them enact and enforce red flag laws, also known as “extreme risk protection orders,” which are intended to restrict potentially dangerous people rather than dangerous weapons.

And Mr. McConnell has asked three committee chairmen to “reflect on the subjects the president raised” and hold bipartisan talks of “potential solutions.”

Red flag legislation also appears poised to move in the House. The Judiciary Committee was consulting with its members on Tuesday about whether to briefly return to Washington from a six-week recess to advance a red flag bill and other gun-related legislation, according to an aide to the committee.

But it is not clear how Democrats will proceed. Some House liberals want still more measures, such as a ban on military-style assault weapons and high-capacity magazines, which directly fuel mass shootings. A House Democratic leadership aide suggested that a red flag bill passed out of the Senate would ideally be attached to tougher House bills to force negotiations between the two chambers.

And a few House Republicans might go along. Representative Adam Kinzinger of Illinois said he had it with the “broken record” debate over gun violence and called for universal background checks, raising the age to buy a gun to 21 and banning some high-capacity magazines “like the 100-round drum the Dayton shooter used this weekend.”

“If we can all recognize the existence of real evil and focus again on respecting each other, and for the love of God quit naming and showing the shooters, we can and will make a real impact,” he wrote Monday on Medium.

a person standing in front of a sign: Protesters outside the National Rifle Association at a vigil for those who died in the shootings over the weekend in El Paso and Dayton, Ohio.© Anna Moneymaker/The New York Times Protesters outside the National Rifle Association at a vigil for those who died in the shootings over the weekend in El Paso and Dayton, Ohio.Seventeen states and the District of Columbia already have laws that allow “extreme risk protection orders.”

The laws authorize courts to issue orders allowing police to temporarily confiscate firearms from a person deemed by a judge as posing a risk of violence. Often, requests for the orders come from relatives and friends concerned about a gun owner who expresses suicidal thoughts or threatens to harm others.

The National Rifle Association, the nation’s largest gun lobbying group, has been fighting extreme risk protection orders in the states for years.

An N.R.A. spokeswoman, Catherine Mortensen, said on Tuesday that any such orders “at a minimum must include strong due process protections, require treatment and include penalties against those who make frivolous claims.”

Gun violence has been one of the most divisive and intractable issues in Washington, and even gun control advocates conceded that getting the House bills through the Senate would be a heavy lift. Senator Patrick J. Toomey, Republican of Pennsylvania, said on Monday that he was reviving his background checks bill, which fell to a filibuster in 2013, and that he intended to press Mr. McConnell to bring it up if Republicans were convinced they had the votes.

“I think we need Manchin-Toomey,” Mr. Toomey said, referring to Senator Joe Manchin III, Democrat of West Virginia, his co-sponsor. “I think it’s overdue. This is a common-sense, very broadly supported measure that would fully respect the rights of law-abiding citizens, fully respect the Second Amendment.”

Already, Democrats are warning that Republicans will use Mr. Graham’s proposal to skirt the larger issue.

“Right now I can sense from my conversations with Republican colleagues that they are really grappling and struggling — scrambling may be too strong a word — but they are really searching for some steps that are meaningful,” Senator Richard Blumenthal, Democrat of Connecticut, who is joining with Mr. Graham on the red flag bill, said on Tuesday. “And there’s nothing more strongly supported by the American people than background checks.”

Mr. Blumenthal and other Democrats are demanding that Mr. McConnell bring the Senate back from its August recess to pass the House bill expanding background checks to internet and gun show purchases, and a second House measure allowing the F.B.I. more time to investigate a would-be gun buyer flagged by the current background check system.

“The idea of a red flag law is O.K., but it doesn’t substitute” for a background checks bill, Senator Chuck Schumer, the Democratic leader, told reporters on Tuesday. “It’s not enough.”

At the White House, Mr. Trump told aides to explore whether he could achieve some gun measure — possibly background checks — through executive action, according to two people briefed on the discussions. However, Mr. Trump expressed a desire to get some form of political concession from his critics in exchange for doing so, according to the people briefed. (After congressional action failed in the wake of the Newtown shooting, President Barack Obama tried to use his executive authority to bolster gun controls but he had little success.)

The evidence for whether extreme risk protection orders work to prevent gun violence is inconclusive, according to a study by the RAND Corporation on the effectiveness of gun safety measures.

But emerging evidence suggests that temporary removal laws can have a measurable effect on suicide deaths when they are enacted and used. Research in Connecticut and Indiana has found that the enforcement of the laws saved lives — about one fewer suicide death for every 10 to 20 cases of gun removals. Suicides represent around two-thirds of all gun deaths in the United States.

Jeffrey Swanson, a professor of psychiatry at Duke University, who studied the laws in both states, said his work showed that the statutes could make a difference, even if they did not prevent mass shootings. Suicide “is certainly an important problem if you think about public health and mortality,” he said.

In states that lack red flag laws, judges typically require a diagnosis of dangerous mental illness before a person is barred from owning firearms. And despite the pronouncements of politicians who are quick to blame mass shootings on people who are mentally ill, research shows that past violent behavior is a much better indicator of whether someone will turn violent. White extremist ideology also drives many deadly shootings.

From 2009 to 2017, about half of the gunmen in mass shootings — those in which at least four people, not including the gunman, are killed — exhibited warning signs before the killings, an analysis by the gun control organization Everytown for Gun Safety found.

“You can call a law enforcement officer and say ‘Uncle Johnny’s in the backyard with a 12-pack of beer and six firearms,’ and they’re going to say, ‘Yes, ma’am, he’s not breaking any law. He doesn’t have a diagnosis of mental illness,’” said Lori Haas, the senior director for advocacy of the Coalition to Stop Gun Violence, which developed a template for extreme risk protection orders legislation after the Newtown massacre. “A lot of dangerous behaviors are not, and would not be, based in a mental illness diagnosis.”

Advocates also point to the 2018 mass shooting at Marjory Stoneman Douglas High School in Parkland, Fla., where the gunman exhibited such troubling behavior, according to one neighbor, that his mother would on occasion call the police. After the massacre, which resulted in the deaths of 17 students and staff members, Florida joined a number of other states in passing red flag laws.

Gun control advocates are enthusiastic about Mr. Graham’s measure. On Monday, John Feinblatt, the president of Everytown for Gun Safety, cited red flag laws as one of his two top priorities, along with background check legislation.

Other bills are circulating as well. Mr. Toomey and Senator Chris Coons, Democrat of Delaware, are proposing a so-called lie and try bill, which would mandate the prosecution of people who try to purchase guns even though they are ineligible.

And House leaders plan to keep the issue of extremist violence in the public view. On Tuesday, the bipartisan leadership of the House Homeland Security Committee sent a letter to Jim Watkins, the owner of 8Chan, the internet message board where violent white supremacists congregate, demanding that he come before Congress and answer questions on the site’s content.

Margot Sanger-Katz and Nicholas Fandos contributed reporting from Washington, and Maggie Haberman from New York.