The man then turned the gun on himself, said Lt.-Gen. Mark A Milley at a Wednesday press conference.
The gunman, whose name is not being released until his next of kin are notified, served for four months in Iraq in 2011.
He was on medication and undergoing treatment for depression, anxiety and some other psychological issues, said Milley. The soldier also self-reported a traumatic brain injury after coming back from Iraq, he said, but it is unclear if it was officially diagnosed.
He used a recently purchased .45 calibre pistol during Wednesday's shooting at a medical centre at the base.
"If you have a weapon and you're on base, it's supposed to be registered on base," said Milley. "This weapon was not registered on base."
Gunman fired shots in 2 buildings
Milley said the timeline for the shooting is still being pieced together by investigators, but they have a rough sequence of events.
The first shots were fired at about 4:04 p.m. local time, he said.
The soldier walked into a building and opened fire. He then retreated to a vehicle and fired from inside it. After he exited the vehicle, the soldier walked into a second building and fired again.
He was then engaged by a responding military police officer.
Milley said the soldier approached the police officer, who was about six metres away. He first put his hands up, but then reached under his jacket and pulled out his pistol.
She engaged, Milley said, at which point the soldier put the pistol to his head. He appears to have died of a self-inflicted gunshot wound to the head.
The officer's actions were "clearly heroic," said Milley, adding that "she did exactly what we would expect of the United States army military police."
One of the two buildings houses the day-to-day administration of the medical brigade, while the other houses the day-to-day administration of the transportation battalion.
'We will get through this'
Three people died and 16 others were injured during the shooting. None of the victims or injured are civilians.
The injuries include gunshot wounds, superficial injuries from shattered glass and an injury received from jumping over a fence.
The injured were taken to local hospitals. Dr. Glen Couchman, chief medical officer at Scott and White Hospital in Temple told the Associated Press that the first four people admitted there had gunshots to chest, abdomen, neck and extremities and that their conditions range from stable to "quite critical."
“Events in the past have taught us many things here at Fort Hood. We know the community is strong, we know the community is resilient," said Milley. "We will get through this."
In 2009, an assault on Fort Hood was the deadliest attack on a domestic military installation in U.S. history. Thirteen people were killed and more than 30 injured.
Federal, state and local officials are investigating the shooting, said Milley.
Milley said there is no indication that the incident was related to terrorism, though it is not being ruled out.
Officials are looking into the shooter's background, checking for any criminal history, looking into his psychiatric history and evaluating his experience in combat.
Milley revealed the soldier is married and had arrived at Fort Hood in February from another installation, which is helping investigate his background.
The soldier was not wounded in combat during his time in Iraq, said Milley.
No motive has been discovered yet.
'Sense of safety has been broken once again'
U.S. President Barack Obama promised that investigators would get to the bottom of the shooting.
He acknowledged the many sacrifices of the people at Fort Hood.
"They serve with valour and they serve with distinction, and when they're at their home base, they need to feel safe," Obama said, speaking without notes or a prepared speech from Chicago. "We don't yet know what happened tonight, but obviously that sense of safety has been broken once again."
He said the shooting reopens the painful memories of the deadly attack at Fort Hood five years ago.
Army psychiatrist Nidal Hasan was convicted and sentenced to death last year in the November 2009 attack. He said he acted to protect Islamic insurgents abroad from American aggression.
Hasan, who was shot in the back by Fort Hood police officers and paralyzed from the waist down during the shooting, is now on death row at a Kansas military prison.
Milley said daily press conferences will be held to update the public on developments from the investigation.