WASHINGTON ― Congress took its final step Wednesday to repeal a Social Security Administration rule that was written to prevent mentally incompetent people from buying guns.

By law, people who have been “adjudicated as a mental defective” by a court or other authority, such as the Social Security Administration, are barred from buying guns and are supposed to be added to the National Instant Criminal Background Check System, or NICS.

But federal officials trying to use the system often complained that the data were incomplete, prompting President George W. Bush to sign the NICS Improvement Amendments Act of 2007.se

Still, little was done to gather data from the various federal agencies that are in a position to know if a person lacks the mental wherewithal, especially because of mental illness, to possess a firearm.

The slaughter of 26 children and teachers at Sandy Hook Elementary School in Connecticut by a mentally ill man in 2012 prompted the Obama administration to renew the effort, leading to the Social Security Administration finally releasing a rule in 2015 that was finalized just last December.

But that rule ran afoul of Congressional Review Act, which lets Congress repeal rules within 60 legislative days of being adopted. Although the Social Security rule took years to develop, it was released in that window.

The GOP-led Senate voted 57 to 43 to revoke the rule Wednesday, following an earlier vote by the House. Independent Sen. Angus King (Maine) and Democratic Sens. Joe Donnelly (Ind.), Joe Manchin (W.Va.), Jon Tester (Mont.) and Heidi Heitkamp (N.D.) voted with Republicans. All five face re-election in 2018.

Republicans, who frequently assert that the way to deal with gun violence is to deal with mental illness, in this case argued that the regulation mistreats disabled Americans.

“This regulation unfairly stigmatizes people with disabilities. If the regulation is not repealed, it will allow the agency to very unfairly deprive Social Security recipients of their Second Amendment rights,” said Sen. Chuck Grassley (R-Iowa). “The regulation would result in disability recipients being reported to the National Instant Criminal Background Check System as ineligible to own a firearm, and thus have their Second Amendment rights violated.”

Grassley added that the rule could apply to such disabilities as “an eating disorder.”

The regulation, however, does not say that any person with a disability would be affected. It is much more narrow. It says people who are unable to deal with their own finances ― requiring a trustee to administer them ― and are unfit because of a disability stemming from a mental problem would have their information sent to the NICS. They could also appeal. People whose mental issues do not stem from their Social Security disability are not included.

The Republicans are so hypocritical on this issue. Sen. Chris Murphy (D-Conn.)

“If we do not find an individual to be disabled based on a mental impairment, he or she has not met the reporting requirements and we will not report them to the NICS,” the Social Security Administration explained in releasing the rule.

Still, some disability advocates do oppose the rule and agree with Grassley, in part. They argue that too many people with mental disabilities are painted with too broad a brush, and that the rule could set a precedent to reduce other rights.

Democrats see little but hypocrisy and opportunism by Republicans, and a desire to assuage the gun lobby.

“The Republicans are so hypocritical on this issue,” said Sen. Chris Murphy (D-Conn.), who became an outspoken critic of gun violence after the Sandy Hook massacre in his state. “They constantly say we should be enforcing existing law, and then they are, at the same time, rewriting the law so that fewer people will be put on the criminal background check system.”

Indeed, Grassley is one of the many Republicans who have argued that focusing on the mentally ill and denying guns to people who should not get them is the best route to reducing gun atrocities. He proposed legislation to improve the NICS just last year.

“A database is only as good as the data it contains, with accuracy and completeness being paramount,” he said in proposing a measure to improve the NICS. “This database needs improvement. In that vein, my amendment requires that agencies containing relevant records make their submission to NICS a priority and provides specific guidance that federal courts are to upload their records to NICS forthwith.”

One federal agency that would no longer be able to upload their records forthwith is the Social Security Administration. One facet of the Congressional Review Act is it specifies that an agency may not write a new rule that is substantially similar to one Congress tossed out. It would likely mean that no rule will be approved soon.

Murphy found the circumstance appalling.

“I don’t know why we think that somebody who literally can’t manage their own financial affairs could be a responsible gun owner,” he said. “I hope something truly awful doesn’t happen because of this.”

Murphy thought there could be a political price to pay.

“In the end, they’re going to do what the gun lobby asks them to do,” Murphy said. “I’m sure that 90 percent of their constituents don’t think that people who are seriously mentally ill should be able to buy a gun, yet that’s what they’re voting to do.”

The National Rifle Association hailed the repeal and said in a statement that it looks forward to Trump signing it.

“Today’s Senate vote was the next step in rolling back some of the egregious government overreach that characterized the Obama era,” said Chris W. Cox, executive director of the NRA-ILA. “Congress is reversing a last-minute, back-door gun grab that stripped law-abiding Americans of their rights without due process.”

President Donald Trump is expected to sign the repeal.

This story was updated to reflect passage of the repeal and with a statement from the NRA.