A soldier shot dead three colleagues and injured 16 others at the US Army's Fort Hood base in Texas before killing himself, the military says.
US media named the suspect as Ivan Lopez, 34, although his identity has not been officially confirmed.
The gunman had served in Iraq and had mental health problems, officials said.
President Barack Obama said he was "heartbroken" over the attack. A gun rampage at the same base in 2009 left 13 soldiers dead and 32 wounded.
Maj Nidal Hasan was sentenced to death for that attack.
He said the suspect had not been injured when he served in Iraq in 2011, but was being assessed to see if he had post-traumatic stress disorder.
The gunman was being treated for depression and anxiety, Gen Milley added.
The general said that it was not clear if the attack was premeditated and those wounded and killed were all members of the military.
The soldier drove to two buildings on the base and opened fire before he was stopped by military police, in an incident that lasted between 15 and 20 minutes.
He then shot himself in the head with a .45-calibre semi-automatic pistol, Gen Milley said. Officials say the weapon had been bought in a local store.
Obama told reporters in Chicago: "I want to just assure all of us we are going to get to the bottom of exactly what happened."
Obama said Ford Hood had sacrificed so much for freedom.
"We know these families. We know their incredible service to our country and the sacrifices that they make. Obviously our thoughts and prayers... are with the entire community," he said.
Defence Secretary Chuck Hagel called the shooting a "terrible tragedy".
Daniel Corbin, mayor of nearby Killeen in Texas, told the BBC he felt nearly "indescribable" grief for those involved.
"We pray for them when they are deployed. We try to take care of their families and we're really close as a community to Fort Hood," he said. "You wish you could, you know, give some immediate help, but you can't."
Maj Hasan was sentenced to death last September over the 2009 rampage.
He claimed he opened fire at the army base to protect Taliban insurgents from US troops who were about to deploy to Afghanistan.
It was the deadliest attack on a domestic military installation in US history.