The US Army has said there is a "strong possibility" that the soldier who killed three colleagues and wounded 16 others at the Fort Hood base in Texas two days ago was involved in an argument beforehand.

It is also believed gunman, who has been formally identified as 34-year-old Ivan Lopez, was battling mental illness when he went on the rampage, the base commander has said.

The soldier took his own life after the gun attack.

No motive was given for the shooting spree on Wednesday, in what was the second mass killing in five years at one of the largest military bases in the United States, raising questions about security at such installations. Officials have so far ruled out terrorism.

"We have very strong evidence that he had a medical history that indicates unstable psychiatric or psychological conditions," Lieutenant General Mark Milley told reporters.

"There may have been a verbal altercation with another soldier or soldiers. There is a strong possibility that that immediately preceded the shooting," said Mr Milley, adding there was no indication that he targeted specific people.

Lopez, originally from Puerto Rico, had been treated for depression and anxiety. He was being evaluated to see if he suffered from post-traumatic stress disorder, or PTSD, military officials said.

He is suspected of smuggling onto the base a recently-purchased Smith & Wesson .45-caliber pistol that was used in the shootings.

Mr Milley said Lopez purchased the firearm at Guns Galore, the same store in nearby Killeen where former Army psychiatrist Major Nidal Hasan bought the weapon he used to kill 13 people and wound 32 others at Fort Hood in 2009.

US Army Secretary John McHugh said Lopez, who joined the service in 2008, had served two tours of duty abroad, including four months in Iraq in 2011. He had no direct involvement in combat and had not been wounded.

"He was undergoing a variety of treatments and diagnoses for mental health conditions, ranging from depression to anxiety to some sleep disturbance.

"He was prescribed a number of drugs to address those, including Ambien," Mr McHugh told a US Senate committee hearing.

In the immediate aftermath of the shooting, US President Barack Obama said: "Our thoughts right now in many ways are with the families at Fort Hood. These are folks who make such extraordinary sacrifices for us each and every day for our freedom."