FORT HOOD, TEXAS — Unstable mental health may be the “fundamental, underlying cause” of a soldier’s shooting rampage at Fort Hood that left four people dead, though an argument with another service member likely preceded the attack, according to investigators.

Spc. Ivan Lopez turned his gun on himself after killing three people and wounding 16 others Wednesday at the sprawling Texas military base, where more than a dozen people were killed by a soldier in 2009. An Army truck driver from Puerto Rico, Lopez was undergoing treatment for depression and anxiety while being evaluated for post-traumatic stress disorder, base officials said.

Lt. Gen. Mark Milley, senior officer at the nation’s largest Army base, said there was a “strong indication” that Lopez was involved in an argument shortly before the shooting, though it doesn’t appear he targeted specific soldiers during the attack. Investigators are also focusing on his mental health.

“We have very strong evidence that he had a medical history that indicates unstable psychiatric or psychological condition,” Milley said. “We believe that to be a fundamental, underlying cause.”

Lopez had reported to medical personnel that he’d suffered a traumatic brain injury. The 34-year-old served four months in Iraq but saw no combat, and he had previously demonstrated no apparent risk of violence.

He seemed to have a clean record that showed no ties to potential terrorists, though military officials said the investigation was ongoing.

“We’re going to keep an open mind and an open investigation,” Army Secretary John McHugh said Thursday in Washington, explaining that “possible extremist involvement is still being looked at very, very carefully.”

Lopez saw a psychiatrist last month and showed no “sign of any likely violence either to himself or others,” McHugh said.

Three of the wounded in Wednesday’s shooting remained in serious condition at Scott & White Memorial Hospital in nearby Temple.

Investigators searched Lopez’s home on Thursday and questioned his wife, who declined to comment in Spanish when reached by phone by The Associated Press.

Lopez walked into a base building around 4 p.m. Wednesday and began firing a .45-caliber semi-automatic pistol. He then got into a vehicle and continued shooting before entering another building on the Army post. He was eventually confronted by military police in a parking lot and shot himself, Milley said.

Lopez bought the weapon he used in the attack at Guns Galore in Killeen — the same store, just off the base, where Army psychiatrist Nidal Hasan purchased an FN 5-7 tactical pistol that he used to kill 13 people and wound more than 30 others in a November 2009 shooting on the base.

After that shooting — the deadliest attack on a domestic military installation in U.S. history — the military tightened base security nationwide.

Lopez grew up in Guayanilla, a town of fewer than 10,000 people on the southwestern coast of Puerto Rico.

Lopez joined the island’s National Guard in 1999, and he served on a yearlong peacekeeping mission in Egypt’s Sinai Peninsula in the mid-2000s. He enlisted with the Army in 2008, and arrived at Fort Hood in February from Fort Bliss, another Texas base.