WASHINGTON ― The House of Representatives passed a bill Thursday to allow thousands of veterans who are disabled or have mental health conditions to buy guns.

Under a law signed by President George W. Bush in the wake of a mass shooting at Virginia Tech in 2007, federal agencies such as the Veterans Administration were required to add the names of people deemed “mentally defective” to the National Instant Criminal Background Check System, or NICS, to block them from buying weapons.

The VA defined such individuals as those who receive monetary benefits, and have a fiduciary because they lack “the mental capacity to manage his or her own financial affairs regarding disbursement of funds without limitation, and is either rated incompetent by VA or adjudged to be under legal disability by a court of competent jurisdiction.”

There are an estimated 174,000 veterans who have been added to the background check system for many different reasons. The VA estimated in 2015 that about 19,000 of those people suffer from schizophrenia, 15,000 have severe post-traumatic stress, 11,000 suffer from dementia, about 5,000 are diagnosed with Alzheimer’s disease, and 4,000 are severely depressed.

The bill, dubbed the Veterans 2nd Amendment Protection Act, stops the VA from referring any of those veterans to the background check system. It passed 240 to 175, on a nearly party-line vote.

Democrats who opposed the measure admitted that some veterans who could safely own weapons were caught up in the system, and said they would be open to a more carefully tailored measure that wouldn’t simply allow every veteran who has a mental illness to buy weapons.

“I support veterans and I support veterans’ rights to defend themselves, but I don’t support crazy people having guns whether they are veterans or not,” Rep. Alcee Hastings (D-Fla.) said. “It’s just that simple.”

Democrats especially pointed to high rates of veteran suicide, noting that of the approximately 20 veterans who take their own lives every day, about two-thirds of them do it with a gun.

“There is a veteran suicide crisis in the country, a crisis that is enabled by the easy access to firearms,” said Rep. Elizabeth Esty (D-Conn.), who offered a counter-proposal that did not pass.

A bipartisan group of retired generals, including David Petraeus, Michael Hayden and Stanley McChrystal, was also critical of the bill.

“For these individuals, possession of a firearm could be fatal,” they wrote in a recent letter to leaders of both chambers of Congress.

“The Veterans 2nd Amendment Protection Act would put at risk the safety of these veterans and our communities by changing the standard for gun prohibition, so the VA’s determinations would no longer stop a veteran from obtaining a gun,” they wrote. “Instead, the names of veterans already in the background check system would be erased, putting them at much greater risk of self-harm. This would be irresponsible, dangerous, and life threatening to those who need access to care, not weapons.”

Republicans argued that the current rules deprive veterans of their Second Amendment rights without due process, although the recently passed 21st Century Cures Act added new steps to ensure veterans can challenge the VA’s decision to add them to the NICS.

Rep. Phil Roe (R-Tenn.), the measure’s main sponsor, said he was “personally devastated” by the alarming veteran suicide rate, but that taking guns away from distressed vets was not the answer.

“Denying veterans who have fiduciaries their constitutional rights will not end veteran suicide,” Roe said. “And it’s unfair to paint all veterans who may need a fiduciary with the same broad stroke, and to assume that just because someone needs assistance with their financial affairs that they may also be violent and a danger, or that they’re contemplating suicide. That’s just plain wrong.”

The National Rifle Association praised the legislation, and urged the Senate to pass a similar bill there.

“The constitutional rights of our veterans must be strongly protected,” said Chris W. Cox, executive director, NRA-ILA. “Needing help managing your money does not make you a danger to society. The NRA is pleased with the House vote today and we look forward to the Senate taking action soon.”

This is the second major move the GOP has made this year to ensure that people with mental health conditions can buy guns. Congress passed a bill last month that blocked the Social Security Administration from referring the names of people who are mentally ill and unable to manage their affairs.

This story has been updated to include comment from Cox.