A US army psychiatrist about to be deployed to Afghanistan allegedly shouted "Allahu Akbar", or "God is greatest", as he opened fire at a military base in Texas, killing 13 people and wounding 28.

Major Nidal Malik Hasan

The gunman, Major Nidal Malik Hasan, 39, shouted the Arabic phrase just before he began his shooting spree at Fort Hood military installation yesterday, according to the base commander, Lieutenant General Robert Cone.

Hasan's family said he had been dreading deployment to Afghanistan.

Cone praised a civilian police officer for stopping the rampage. Sergeant Kimberly Munley and her partner responded within three minutes of reported gunfire. Cone said Munley shot the gunman four times despite being shot herself. "It was an amazing and an aggressive performance by this police officer," he said.

Twelve of those killed were soldiers; one was a civilian. All of the wounded were in a stable condition, officials said at a press conference today. Among them are Hasan himself and Munley.

Contrary to initial reports, Hasan is alive but has not yet been interviewed by investigators as he is on a ventilator. "He is in a stable condition," an army medical spokesman said.

Commander Colonel Steven Braverman, who was a colleague of Hasan at the Darnall army medical centre on Fort Hood, said Hasan performed well in his job and had showed no obvious signs of trouble. "We are not aware of any problems that he had while he was here at Darnall," said Braverman, adding: "We had no problems with his job performance while he was working with us." Braverman confirmed Hasan had received orders to deploy to Afghanistan.

One of Hasan's cousins, Nader Hasan, told reporters he had been dreading going to war, having counselled scores of returning soldiers for post-traumatic stress disorder. "He was mortified by the idea of having to deploy," the cousin said. "He had people telling him on a daily basis the horrors they saw over there."

Family and fellow officers said Hasan had complained of harassment by other troops about his Middle Eastern ethnicity and Muslim faith.

The FBI was last night going through Hasan's phone and computer records to see if a motive could be identified. Agents were checking back on website postings by a man who identified himself as Nidal Hasan that appeared sympathetic to suicide bombings.

At about 1.30pm yesterday, Virginia-born Hasan is said to have opened fire with two handguns at the base's soldier readiness centre where troops were having equipment checks, dental treatment and undergoing other preparations before being flown to Iraq or as they returned from combat. Neither of the guns are believed to have been military issue.

Ford Hood's deputy base commander, Colonel John G Rossi, said about 500 soldiers were in the area when Hasan entered the centre wearing military uniform. He shot some victims at close range and others were injured as the bullets ricocheted, Rossi said.

Troops are not allowed to carry firearms on the base and armed military police quickly swarmed to the scene.

Soldiers tore up their uniforms to bandage the injured. Troops at a graduation ceremony nearby, attended by 600, have been praised for quickly blocking the doors when the firing began.

The base went into lockdown for several hours amid fears other gunmen were involved. Greg Schanepp, who was representing a local congressman at the graduation, told how a soldier who had been shot in the back came running towards him and alerted him to the shooting, telling him not to go in the direction of the killer.

The base commander, Cone, said only military police on the base carried guns. He did not speculate on a motive. Two other people were questioned and then released.

Federal law enforcement officials told Associated Press that Hasan had come to their attention at least six months ago because of his web postings, which discussed suicide bombings and other threats.

One of the web posts that authorities reviewed was a blog that equated suicide bombers with a soldier throwing himself on a grenade to save the lives of his comrades. "To say that this soldier committed suicide is inappropriate. It's more appropriate to say he is a brave hero that sacrificed his life for a more noble cause," said the post. "Scholars have paralled [sic] this to suicide bombers whose intention, by sacrificing their lives, is to help save Muslims by killing enemy soldiers."

The officials said Hasan appeared to have made the postings but it was still being checked.

The wounded were taken to hospitals in the central Texas region. Lisa Pfund said her daughter Amber Bahr, 19, was shot in the stomach and was in a stable condition.

Barack Obama, interrupting a speech in Washington, said the incident was a "horrific outburst of violence".

The gunman showed no signs of worry or stress when he stopped at a convenience store for his daily breakfast of hash browns, said Jeannie Strickland, manager of a local 7-Eleven. "He came in [Thursday] morning just like normal," she told the Houston Chronicle, "nothing weird, nothing out of the ordinary."

Video footage was shown on CNN last night apparently of Hasan in a shop in the morning ‑ about six to seven hours before the shooting ‑ looking relaxed as he bought some goods.