Correction: A previous version of this article incorrectly said that Barbara Van Dahlen is a psychiatrist. She is a licensed clinical psychologist. This version has been corrected.

Aaron Alexis’s erratic and violent behavior was ignored, overlooked or dismissed for nine years by police, the military, the Department of Veterans Affairs and his employer, creating a series of missed opportunities that might have stopped the Navy Yard gunman, according to records and interviews with officials close to the investigation.

The warning signs were stark but never detected or communicated among agencies, allowing Alexis to move freely around military bases with a secret-level security clearance.

Alexis was arrested three times in three states for acts of rash, inexplicable violence. He told Seattle police in 2004, for example, that he’d had an anger blackout so intense that he couldn’t recall shooting three rounds from the .45-caliber Glock he usually kept strapped tightly to his waist.

An upstairs neighbor in Texas in 2010 told police she was terrified of him after a gunshot came through the floor a few feet from where she was sitting.

Three other times, in other states, he was cited in police reports for acts of aggression or hallucinations.

Twice, medical staff at swamped Veterans Health Administration emergency rooms in Providence, R.I., and the District failed to pick up on Alexis’s deteriorating mental stability, despite new protocols designed to screen for it, the records and interviews show.

Navy security officials, warned in August by police in Rhode Island that Alexis was hearing voices, a key indicator of a mental break, failed to notify the technology company where he worked, a Navy official said, nor did they appear to pass the information up the chain of command.

Alexis’s employer, an IT company called the Experts, was so concerned about Alexis’s increasingly agitated state over the summer that they called his mother and sent him home to rest, but they say they did not share their concerns with the Navy.

His outbursts never made it into a national database that would have notified police among different jurisdictions and turned up in background checks for gun purchases, enlisting in the military or obtaining a mid-level secret security clearance. That system is designed to catch Cold War-era spies intent on selling national secrets, not monitor people for mental health problems.

In fact, some experts said, his security clearance, rather than acting as an early warning system, actually helped Alexis avoid greater scrutiny. His clearance was an indication for many that Alexis could be trusted.

The VA staff, trained to catch and treat such mental instability, often are so overworked and understaffed that they fail to do so, the records and interviews indicate. And military and company officials failed to act on clear warning signals that Alexis was spiraling dangerously out of control.

And so on Monday, about 8:15 a.m., Alexis, who was known for his explosive temper and smoldering grudges, who sought refuge from his jangled thoughts at Buddhist temples and in meditation, and who had been estranged from his family for years, quietly slipped onto the Washington Navy Yard base with a sawed-down Remington 870 shotgun hidden in a bag. He emerged from a bathroom and killed 12 people before police shot him dead.

“The fact is, the VA missed the diagnosis. Twice,” said retired general Stephen Xenakis, a military psychiatrist and former adviser to the Joint Chiefs of Staff. “And that’s not the only shortfall.”

Veterans Affairs

On Aug. 23, and again five days later, Alexis sought help for insomnia at the emergency rooms of two Veterans Affairs medical facilities. In each case, VA officials say, he was asked if he was depressed or anxious or had thoughts of harming himself or others. Those questions became standard after a 2007 lawsuit forced VA to adopt better mental health screening because of a disturbing rise in veteran suicides.

Alexis denied such negative thoughts and appeared “alert and oriented,” according to a memo that the Department of Veterans Affairs sent to Congress.

Each time, he was prescribed what law enforcement officials confirmed was trazodone, one of the early antidepressants now more commonly used as a sleep aid. Each time, he was told to follow up with a primary care physician. And each time, he was released.

The insomnia complaint, said Barbara Van Dahlen, a clinical psychologist who works with military families, should have been a warning. “A sleep disturbance, unless it’s a physical issue, that you’ve got pain and can’t sleep, is pretty much about some kind of internal agitation, depression, anxiety,” she said.

Brewster Rawls, an attorney for veterans seeking health care from the VA, said such treatment is all too common in understaffed VA medical facilities. Veterans have difficulty being seen, experience long delays before treatment and often are prescribed pills after a cursory exam and sent on their way, he said.

The VA memo said that Alexis had canceled or failed to show up for appointments. But it is unclear whether Alexis had a primary care physician coordinating his care. Friends in White Settlement, Tex., where Alexis lived most recently, said he often talked about seeing a VA counselor for post-traumatic stress disorder.

A number of recent audits of VA’s mental health system mandated by Congress have found that the system is overloaded, as the number of veterans seeking mental health services has more than tripled, from 400,000 to 1.3 million, in the past seven years.

Despite an increase in its mental health budget and a push to hire more mental health practitioners, a 2012 audit found that three out of four facilities visited had no psychiatrist on staff.

Xenakis said it takes an experienced clinician to recognize hidden symptoms and build trust.

“These guys who are psychotic come in, and they may complain of sleep problems, but they look bizarre, they act different. Sometimes, particularly if it’s their first psychotic break, they don’t know what’s happening to them,” Xenakis said. “They’re essentially asking for help in their actions. It becomes the responsibility of the health-care system to be aware of that and to then intervene effectively. Those checklists will often miss this kind of problem.”

If VA missed a diagnosis of Alexis, the doctors may have exacerbated that by prescribing a potentiality dangerous drug for someone in his state, Xenakis said.

Trazodone is generally thought to be a safe drug, but in some patients with psychiatric issues, there’s a danger that some antidepressants could make things worse.

“The last thing you want to do is give an antidepressant to someone who’s in a manic episode or who’s disturbed by hallucinations and bizarre ideas,” Xenakis said. “That can aggravate the condition.”

The VA medical system missed at least two other opportunities to catch Alexis’s mental health issues, Xenakis said.

Alexis sought and received disability ratings from VA, one in December 2011 for orthopedic issues — his friends remember him complaining about a numb foot — and again in December 2012 for ringing in the ears. Both were opportunities, Xenakis said, for full physical and mental health work-ups.

But Ronald Abrams, who helps veterans with benefits claims for the National Veterans Legal Services Program, said that rarely happens.

“They will do a psychological evaluation,” he said, “but unless you’re frothing at the mouth, they’re not going to pay much attention to it.”

At a minimum, Xenakis said, Alexis’s tinnitus should have caused concern. Veterans exposed to loud blasts and explosions will often complain of tinnitus, or ringing in the ears, he said.

“Then you have to ask, does he have mild traumatic brain injury?” Xenakis said. “Or post-concussion syndrome, which would have further aggravated his mental state.”

VA officials declined to comment beyond a memo they gave to Congress soon after the Navy Yard shooting.

The military

Alexis also displayed erratic behavior during his time as a Navy Reservist from 2007 to 2011, which could have sparked intervention.

A former colleague at the Fleet Logistics Support Squadron VR-46 said those serving with Alexis saw a swift transformation in the electrician who worked on C-9 aircraft during his last two years in uniform.

“He started taking a turn with his attitude and became very short-tempered,” said the former colleague, who spoke on the condition of anonymity because of the sensitivity of the shooting. “He had problems with authority, with people telling him what to do.”

During social gatherings in Georgia, where the unit was based when he joined, and later in Texas, Alexis would often storm out angrily. Sometimes he would yell or physically threaten someone who had angered him, the former colleague said. Once, he pulled a weapon, the person recalled.

“To all of us at work, he looked like he had anger management issues,” the former colleague said.

Alexis was discharged from the Navy in 2011 after a pattern of insubordination and mysterious absences. Yet it’s unclear if the misconduct, often an indicator of underlying mental illness, Xenakis said, prompted a physical and mental health exam, as protocol requires.

The police

In Rhode Island last month, Alexis repeatedly complained to the Experts that he couldn’t sleep and that he heard voices. The company twice agreed to move him to different hotels, a company official said.

Alexis had never slept well and had long worked or played video games through the night, said Melinda Downs, a friend from White Settlement, outside Fort Worth. But in August, she said, his insomnia got so bad that his company contacted family members and sent him home to rest.

“He said, ‘I can’t believe HR called my mom,’ ” Downs recalled.

On Aug. 7, Alexis called police in Newport, R.I., and said the people he had argued with at the airport had sent three people to follow him. They were sending vibrations into his body with a microwave machine and keeping him awake, he said, and he could hear their voices coming through the walls, the floor and the ceiling, according to the police report.

“We see numerous cases like this every day,” said police Lt. William Fitzgerald. “He didn’t appear to be a danger to himself or to anyone, so we had no reason to submit him to a mental health evaluation.”

Over the years, Alexis was arrested three times and once spent two nights in jail, but he was never charged or prosecuted. The national criminal database that police use to check someone’s background contains only convictions.

In 2004 in Seattle, detectives were preparing to charge Alexis with a felony for shooting out the tires of a construction worker’s car, said Sgt. Sean Whitcomb, a spokesman for the Seattle Police Department. If convicted, Alexis would have been prohibited from buying a firearm for five years, according to Dan Donohoe, spokesman for the King County prosecutor’s office.

The charge could also have made it difficult if not impossible for Alexis to enlist in the Navy three years later, requiring him to obtain a waiver that would have brought additional scrutiny.

But authorities knocked the charge down to a misdemeanor. Then the paperwork was lost. And though he had confessed to the crime, no charges were ever brought.

Had he been charged, Donohoe said, a judge potentially could have referred him to anger management or counseling services. A conviction would have created a flag in several databases.

Security clearance

Alexis’s angry and erratic behavior never triggered a security clearance review.

The Defense Department approved Alexis for secret-level clearance in March 2008, a status that can be good for as long as a decade if someone keeps a clean record. Alexis’s employer, the Experts, twice ran its own background checks on him, which the company said turned up nothing but a minor traffic violation.

In Rhode Island in August, within an hour of talking to Alexis, the Newport police faxed the report on Alexis to the naval station’s security office, Fitzgerald said.

A Navy official confirmed that the report did not seem to get beyond that point.

“You have to applaud the Newport police for following up and alerting the Navy base,” said Charles Sowell, a former senior deputy to Director of National Intelligence James R. Clapper Jr. “They could have just put it into the file in their records, but they went the extra mile. That is certainly information that should have made its way into the right hands in the Navy.”

In addition, the Navy official said that the Navy can find no evidence that Alexis’s employer alerted them to concerns or problems they were having with Alexis’s behavior in August.

An official from the Experts said they contacted the Newport police shortly after Alexis told them he’d called them. But they did nothing further, he said.

Once someone has obtained clearance, there are few ways officials can be alerted to mental health problems that develop. Health-care professionals are required to report anyone they believe is likely to harm themselves or others. And people are encouraged to speak up if they know their co-workers are struggling with mental health problems.

Military contractors are required to report “adverse information” about any of their employees with security clearances to an on-site security officer.

Once a report is made that could lead to a reassessment of someone’s clearance status, security officials enter the information into the Joint Personnel Adjudication System, a database that tracks military personnel and civilians with classified access. Those incidents are then immediately reviewed by Defense Department adjudicators.

No information about the microwave machine or voices made it into Alexis’s file, Navy officials said.

“This guy just really fell through the cracks,” said Leslie McAdoo Gordon, a lawyer and former Defense Department special agent who conducted background investigations. “In a perfect world, that immediately gets forwarded to someone who recognizes, ‘We need to check this.’ Theoretically, that could have been done in a few days, and his clearance could have been red-flagged.”

Leslie Minora in Fort Worth and Alice Crites, Matea Gold, Steve Vogel, Ernesto Londoño, Magda Jean-Louis, Jennifer Jenkins and Julie Tate in Washington contributed to this report.