Killeen, Texas (CNN) -- A man opens fire at a military base, gunning down fellow soldiers before ending his own life. A hero steps in, trying to stop him. A community already scarred by war is left reeling, nearly five years after authorities vowed to improve security when another mass shooter struck there.
A day after a shooting rampage at Fort Hood, Texas, left three soldiers dead and 16 wounded, a key question looms over the investigation: Why?
Authorities are still piecing together the answer, but seem to be homing in on at least one thing that they say might have made 34-year-old Spc. Ivan Lopez pull the trigger.
"We have very strong evidence that he had a medical history that indicates an unstable psychiatric or psychological condition. (We're) going through all records to ensure that is, in fact, correct. But we believe that to be the fundamental underlying causal factor," Lt. Gen. Mark Milley, the post's commanding general, told reporters Thursday.
The rampage started around 4 p.m. Wednesday, when Lopez fired his .45-caliber handgun at two buildings at the sprawling Texas military facility. When a police officer confronted him later, he put the gun to his head and pulled the trigger, ending his life.
The gunman was an experienced soldier who was grappling with mental illness, officials said. But they haven't pinpointed why he opened fire.
Authorities are interviewing witnesses and "looking at what the trigger event was" that led to the shooting, including a possible altercation with a fellow soldier "that immediately preceded the shooting," Milley said.
Investigators say they haven't found any links to domestic or international terrorist organizations, but they're keeping open minds.
"At this point we have not yet ruled out anything whatsoever," Milley said. "We are committed to letting the investigation run its course."
Another key question for investigators: did any gaps in safety and security measures allow the shooting to take place?
"Obviously something went wrong," U.S. Defense Secretary Chuck Hagel told reporters on Thursday.
But he stressed that investigators were still trying to piece together the events leading up to the shooting.
"We know a lot of things 24 hours later, but we don't know everything," Hagel said. "What happened? What motivated this person to do this? Where was the gap? Why did we have a gap? Why did it happen? ... I think we are going to find out, and we will do everything possible to implement those reforms and fill those kinds of gaps."
Lopez had a history of depression, anxiety
The native of Puerto Rico enlisted in the Army as an infantry soldier and was deployed twice, including a four-month stint in Iraq as a truck driver, Milley said.
He served in the National Guard in Puerto Rico from 1999 until 2010, when he left the Guard to become an active duty infantryman in the U.S. Army.
Before coming to Fort Hood, Lopez served at Fort Bliss in Texas.
Lopez arrived at the Fort Hood in February, moving with his wife and their daughter into an apartment a little more than a week before the shooting.
They appeared to be a normal couple, said neighbor Xanderia Morris. "They would smile whenever they'd see someone," she said.
But behind Lopez's smile lay a history of depression, anxiety and other psychiatric disorders, Milley told reporters. The soldier was receiving treatment and taking antidepressants, Milley said.
He had served for four months in Iraq in 2011. And while Army records don't show him as having been wounded there, Lopez himself reported that he had suffered a traumatic brain injury, Milley said.
And he was undergoing diagnosis procedures for post-traumatic stress disorder.
"He was not diagnosed, as of today, with PTSD," Milley said.
Arriving at a PTSD diagnosis, which is common among war veterans, can take time.
The shooter "had a clean record" behaviorally, Army Secretary John McHugh said. There were "no major misbehaviors that we're yet aware of," he said.
Lopez had been prescribed the sedative Ambien, McHugh said.
Though he had been diagnosed with depression, anxiety and sleep disturbances, Lopez gave no sign during a psychiatric exam last month that he was likely to commit violence against himself or others, McHugh said. "So the plan (going) forward was just to continue to monitor and treat him as deemed appropriate."
Mary Ellen O'Toole, a former senior FBI profiler, warned against blaming mental health problems for the violence.
"I'm really stunned by the general saying that the underlying cause is unstable mental health ... many people in the world have unstable mental health. Many people take Ambien. They don't go out and kill themselves and kill other people," she said. "Unstable mental health can be one of the risk factors for someone deciding that that's what they're going to do. But it's not the only risk factor."
Spree ended as gunman faced police
The rampage started when Lopez walked into an administration building at the base and opened fire. He then got into a car, fired from the vehicle, got out of the car, walked into another nearby administration building and fired again.
During the minutes of gunfire, he killed three and wounded 16 -- all of them Army personnel, Milley said.
Authorities have "no indication at this time" that Lopez was targeting specific soldiers when he opened fire on the Army post, Milley said.
The shootings took place in the medical brigade and the transportation battalion buildings. Lopez was assigned to the 13th Sustainment Command, which deals with logistics.
The base, which has more than 45,000 soldiers and nearly 9,000 civilian employees, went on lockdown in the aftermath of the shooting Wednesday.
People were told to shelter in place.
The all-clear wouldn't go out for another six hours.
Four minutes after the first 911 call, a law enforcement officer arrived at the scene, Milley told reporters on Thursday.
"A short time later," Milley said, she came face to face with Lopez. Both drew their weapons, and Lopez shot himself in the head, Milley said.
The news hits home
At the Lopez apartment, the shooter's wife was watching the news.
She came out crying, worried about her husband, from whom she had not heard all afternoon. But she had no idea that he was the shooter, said Morris, the neighbor.
"I'm just worried, I'm just worried," Lopez's wife told her.
"I tried to console her and comfort her, let her know everything was OK," Morris said.
It was not. When a local TV station identified the dead gunman as Lopez, his widow became "hysterical," Morris said.
Officers picked up Lopez's widow at their apartment near the base in Killeen, and she was cooperating with law enforcement, an FBI official told CNN.
Sgt. Timothy Owens was one of the soldiers killed in the shooting, his family said in a statement.
"He was a very outgoing person and enjoyed Taekwondo," the statement said. "He loved his job in the army and was going to make it a career."
Daughter Loredana Owens posted about her father's death on Facebook:
"I still feel like it's all a dream.... Can't feel anything ... I just want everyone to think for a moment .... If you have family your fighting with forgive them, love them, because you never know when there gonna be taken from you ..... I love (you) dad and I hate that you were taken away from me."
Three of the wounded who had been in critical condition were upgraded to serious condition on Thursday, hospital officials said. Six of the soldiers wounded in the shooting had been treated and released from hospitals by Thursday evening.
Doctors said it was too soon to say what the long-term impact of the injuries could be.
Their wounds may heal, said Dr. Matthew Davis, medical director of trauma services at Scott & White Memorial Hospital.
But he predicted that the actions of a man who himself may have had PTSD will likely be responsible for others experiencing it.
"They will all have significant emotional wounds as they move forward from this, and that's going to be important for us to recognize," he said.
'How can this possibly happen again?'
When he first heard about the shooting, Davis says one thought ran through his mind: "How can this possibly happen again?"
Less than five years ago, the hospital where Davis works treated casualties after Army Maj. Nidal Malik Hasan killed 13 people and wounded another 32 in a November 2009 shooting rampage at Fort Hood.
Hasan was convicted of 13 counts of murder and 32 counts of attempted murder, and a military jury recommended last August that he be put to death.
The former military psychiatrist told a court that he was on a terrorist mission.
During a hearing in June, Hasan said that he fired at soldiers preparing to deploy to Afghanistan to protect leading members of the Taliban.
Even though authorities haven't found any terrorist ties to Wednesday's shooting, many are comparing it to Hasan's rampage.
"That was so similar, it just tore up my heartstrings," Staff Sgt. Patrick Zeigler told CNN's "New Day" on Thursday.
Zeigler, who is still recovering from four bullet wounds to the head and body from the 2009 Fort Hood shooting, expressed surprise.
"It's just hard to believe that these people that you serve with, who are your brothers in arms, would turn against you," he said. "And it's just incredible that at home, someone in the environment of a military base would decide to do this."
He said security procedures will never suffice to deter someone bent on committing such an act. "It takes somebody brave enough to report these people in order for it to be prevented."
Lopez carried out Wednesday's killings with his own gun -- a .45-caliber Smith & Wesson semiautomatic pistol he bought after arriving in Killeen.
By taking it onto the post, he was breaking the rules.
"If you have weapons and you're on base, it's supposed to be registered on base," Milley said. "This weapon was not registered on base."
In addition, people who are not military police are not allowed to walk around with guns on a military base. They are required to store them in an armory.
Both Lopez and Hasan bought their weapons at Guns Galore, a gun store in Killeen, according to U.S. law enforcement officials who have reviewed the records.
Lopez, who had no criminal history, passed the standard background check, they said, adding that the gun store did what was required.
A man who answered the phone Thursday at the store cited the ongoing nature of the investigation and referred a caller to local law enforcement. "We don't have anything to release," said the man, who would not identify himself.
The store also sold ammunition and gunpowder to Pvt. Jason Abdo, an AWOL soldier who was arrested in 2011 for plotting to attack a restaurant near Fort Hood while it was filled with soldiers and their families.
The plot unraveled when the store alerted authorities that Abdo seemed suspicious. He is serving a sentence of life in prison.
Former Army Staff Sgt. Alonzo Lunsford, who was shot seven times by Hasan, says he felt anger and disbelief when he heard about Wednesday's shooting.
"It has been basically five years since our shooting occurred. And here it is, the same base. ... You have to wonder, five years later, have we learned anything from the shootings that happened with us? What progress has been made?" he told CNN's Michael Smerconish. "There has been some (progress) that has been made. Is there room for more? Yes, there is."
Army Chief of Staff Gen. Ray Odierno credited procedures that were put in place after the Hasan massacre for mitigating the carnage that could have resulted Wednesday.
The procedures and responses prevented "something that could have been much, much worse," he told the Senate Armed Services Committee.
But the recurrence weighed on Killeen Mayor Dan Corbin.
"As a community, it's like you've been kicked in the gut," he said. "It can't be happening again."
No community should have to experience such violence once, let alone twice, said John Cornyn, a U.S. senator from Texas.
"Tonight, Texans' hearts are once again very heavy," he said Wednesday. "The scenes coming from Fort Hood today are sadly too familiar and still too fresh in our memories."
CNN's Joshua Rubin reported from Killeen, Texas; Catherine E. Shoichet and Tom Watkins reported and wrote from Atlanta. CNN's Ben Brumfield, Greg Botelho, Devna Shukla, Dana Ford, Steve Almasy, Nicole Dow, Greg Botelho, Evan Perez, Shimon Prokupecz, Pamela Brown, Brian Todd, Matt Smith, Barbara Starr, Dorrine Mendoza, Carma Hassan and Devon Sayers contributed to this report.