A soldier with "mental health issues" killed three people and wounded 16 before turning the gun on himself at Fort Hood, the military base devastated by a deadly 2009 shooting rampage.
Base commander Lieutenant General Mark Milley said the gunman, who served in Iraq in 2011, was being treated for depression and anxiety, and being checked for possible Post-Traumatic Stress Disorder (PTSD).
All of the dead and wounded were military personnel. At least four of those injured were hospitalized in critical condition.
"At this time, there is no indication that this incident is related to terrorism, although we are not ruling anything out," Milley told reporters at the sprawling US army installation in Texas.
"We do not know a motive. We do know that this soldier had... mental health issues, and was being treated for that."
The gunman -- who was not immediately identified pending notification of next of kin -- used a .45-caliber semi-automatic pistol, which he bought recently and apparently smuggled onto the base.
He opened fire in a medical building, got into a vehicle while still shooting and then went to another building.
The assailant shot himself in the head when he was engaged in a parking lot by an armed female military policewoman, said Milley.
"A military police officer responded and he was approaching her at about 20 feet," he said.
- Gunman shot self in head -
At that point the gunman "put his hands up, then reached under his jacket, pulled out the (gun). She pulled out her weapon, she engaged, (then) he put the weapon to his head and died of a self-inflicted wound," he said.
The general praised the servicewoman's courage, saying it was "clearly heroic."
Milley said the Fort Hood gunman was "currently under diagnosis for PTSD but had not been diagnosed with PTSD." The shooter, who was married, was on medication and had reportedly told officials that he had suffered a traumatic brain injury.
CBS News and other media, citing unnamed sources, identified the shooter as a 34-year-old Army specialist.
The US army base remained on lockdown for a couple of hours after staff were ordered to shelter in place, but personnel and family members were later given the all-clear.
The incident sparked memories of the November 2009 shooting at Fort Hood, when Major Nidal Hasan opened fire at the base, killing 13 people and wounding more than 30 others.
Hasan, who was shot during the attack and is partially paralyzed, was sentenced last year to death. The US-born Muslim of Palestinian descent is awaiting execution.
President Barack Obama said he was "heartbroken something like this might have happened again," and pledged that investigators would "get to the bottom of what happened."
"Obviously, this reopened the pain of what happened at Fort Hood five years ago," Obama said.
"Many of the people there have been on multiple tours in Iraq and Afghanistan. They serve with valor, they serve with distinction. At when they're at their home base, they need to feel safe."
Obama convened a conference call later with Defense Secretary Chuck Hagel, FBI Deputy Director Mark Giuliano and other leaders from Air Force One, as he was returning from Chicago to Washington, the White House said.
- Massive US base -
Fort Hood is spread out over almost 900 square kilometers, and is the largest US military base, with a population of 70,000 including 42,000 military personnel. The rest are family and civilian staff.
The biggest unit stationed there is the 1st Cavalry Division with 17,000. One of its brigades is slated to be deployed in Europe this year on a rotating basis with European partner countries.
The shooting at Fort Hood was the most serious incident of its kind at a US military installation since September last year, when civilian contractor Aaron Alexis killed 12 people at the Washington Navy Yard with a sawed-off shotgun.
Last month, a 35-year-old gunman shot and killed a sailor on board the USS Mahan, a guided-missile destroyer, at Naval Station Norfolk, America's largest naval base in Virginia.