The man accused of killing a West Virginia sheriff wasn’t allowed to possess a firearm but was still able to buy a gun from a local dealer, even though the dealer ran the required background check, a prosecutor said Wednesday.

Mingo County Prosecutor Michael Sparks said there was a delay at the state level in reporting information to a national database that would have disqualified the suspect from gun ownership. That enabled Tennis Melvin Maynard to purchase the gun used to kill Sheriff Eugene Crum on April 3 as the lawman ate lunch in a downtown Williamson parking lot.

“It appears the local dealer did what was legally required under the law,” Sparks said. “The breakdown happened somewhere else. There was a delay in the reporting of the necessary information. Really, an inexcusable delay.”

While Sparks wouldn’t elaborate on why Maynard was barred from owning a gun, Maynard’s father has said his son had mental problems and had previously been in an institution.

Federal law prohibits the sale of firearms and ammunition to certain individuals with a history of mental illness. States are required to share the names of mentally ill people with the national background-check system, which was established under the 1993 Brady Bill.

In West Virginia, such information is supposed to be automatically reported to the FBI, which conducts background checks through its Criminal Justice Information Services Division in Clarksburg. CJIS Division spokesman Steve Fischer said the division doesn’t comment on specific background checks.

The 2007 Virginia Tech massacre prompted passage of legislation requiring states to submit mental health records to the national database or risk losing up to 5 percent of the federal funding they receive to fight crime.

At Virginia Tech, student Seung-Hui Cho shot 32 people to death and committed suicide. He was able to buy two guns, even though he had been ruled a danger to himself during a court hearing in 2005 and was ordered to undergo outpatient mental health treatment.

While the name of the gun shop that sold Maynard the weapon wasn’t disclosed, Sparks said it was a local store.

Sparks said the incident that would have barred Maynard from buying a gun happened about a year before it was reported to the database. Maynard attempted to make additional gun buys but was red-flagged during subsequent background checks, he said.

“The system did work for later attempts to purchase,” Sparks said.

Authorities have declined to say whether Maynard had a concealed weapon permit.

While gun dealers are required to run background checks on firearm sales, West Virginia has no such requirement for sales among individuals, said Sgt. Michael Baylous, a State Police spokesman.

Maynard was shot and wounded by a Mingo County deputy in a chase following the attack on Crum. State Police say he crashed his car into a bridge in his hometown of Delbarton, then got out and pointed a weapon at the deputy, who shot him in self-defense.

State Police say Maynard is up and moving at a Huntington hospital. Authorities have charged Maynard with first-degree murder and attempted murder.