What is publicly known about the mental troubles of the Washington Navy Yard killer, Aaron Alexis, underscores the importance of passing Sen. Lindsey Graham’s bill to close the gaps in background checks for gun buyers.

Sen. Graham, R-S.C., has introduced legislation to broaden the criteria for listing seriously mentally ill individuals on the FBI’s list of people not entitled to purchase weapons.

While endorsed by the National Rifle Association, it has not made progress, probably because the focus has been on more controversial efforts for tougher gun control legislation, including an assault weapons ban.

Sen. Graham’s bill was filed after Alice Boland, who had previously been adjudged mentally ill, was charged with attempting to shoot officials outside Charleston’s Ashley Hall School in February. She squeezed the trigger, police said, but the gun didn’t fire.

The two cases highlight shortcomings in gun laws as they relate to people with mental illness. They show cracks in the system that should identify potential gun purchasers who have previously demonstrated dangerous behavior.

Restricting the purchase of firearms in that regard is a prerequisite to improving the nation’s systems for helping people who are a danger to themselves and others because of mental illness.

Alice Boland was charged in 2005 with making threats against President George W. Bush. She pleaded not guilty by reason of insanity to the felony charge of threatening the president. Four years later, the case was dropped.

Ms. Boland’s record of an arrest for making threats against the president, her diagnosis of mental illness, and a requirement for mandatory treatment were not included in FBI records used for background checks when purchasing a gun, because they did not meet the current legal criteria for inclusion.

That’s a dangerous lapse in the process that Sen. Graham’s bill would address.

Similarly, South Carolina’s Legislature passed a law, in the wake of the Boland episode, that establishes state database of people deemed by the courts to be mentally incompetent or who have been involuntarily sent to a mental institution.

The database would be consulted when people attempt to purchase a firearm from a licensed dealer. Like federal gun laws, however, the state law does not apply to private sales.

The Washington Navy Yard shooter, Aaron Alexis, had a decade-long background of trouble with the law over firearms incidents that exhibited his mental problems, but somehow his records failed to note these incidents or prevent him from obtaining a security clearance and Navy pass — and the gun used in the shooting.

In the most revealing incident, Mr. Alexis called Newport, R.I., police in August to complain that he was being followed by “voices speaking to him through the wall, floor and ceiling,” saying that he had changed motels three times to avoid them. Police notified the Navy but took no action.

And there was nothing in his record to alert police to his misuse of firearms misuse. Nor does Rhode Island have a mandatory treatment law.

Mr. Alexis also sought psychiatric help from the Veterans Administration twice in August, but apparently was not admitted to the hospital for evaluation.

According to the Treatment Advocacy Center, over 1,000 homicides a year are attributable to people with severe mental illness, in part because courts, law enforcement, medical personnel and families are unaware of the risks and the avenues for help.

The Alexis case, which left 13 dead, tragically underscored why those shortcomings must be addressed.

Improving diagnosis and access to treatment are important public safety issues.

So are additional curbs to gun access.

Passing Sen. Graham’s bill is one way to recognize that fact, and move toward a solution.