US government officials have said that Hasan, who is recovering at a military hospital after being shot by police at the end of the attack, is to be charged in a military court over the shooting.

Hasan was in a coma but has now regained consciousness and has talked to his lawyer.

US officials have said that intelligence agencies first started investigating Hasan last December, reviewing what they believed to be email communications between him and a Muslim cleric in Yemen who was known for his anti-American teachings.

Anwar al-Awlaki served as an imam at a mosque near Washington DC where Hasan worshipped, until 2002.

Federal officials ended the investigation after concluding that Hasan's communications were related to research he needed to work as a psychiatrist at the Walter Reed Medical Centre, situated inside the US base.

But in a blog posting on Monday, al-Awlaki wrote: "Nidal Hasan is a hero. He is a man of conscience who could not bear living the contradiction of being a Muslim and serving in an army that is fighting against his own people.

"In fact the only way a Muslim could Islamically justify serving as a soldier in the US army is if his intention is to follow the footsteps of men like Nidal."

Search for motive

Investigators are trying to establish the motive for the shootings.

Hasan's family said he was trying to avoid being deployed to Afghanistan

Hasan, who was known to be against the US-led wars in Iraq and Afghanistan, was supposed to be deployed to Afghanistan this month but his family said he was trying to get out of the assignment.

Hasan's family attended the Dar al-Hijrah Islamic Centre in Falls Church, Virginia, where al-Awlaki was preaching in 2001.

The funeral of Hasan's mother was held at the mosque on May 31, 2001, according to her obituary.

That was around the same time two 9/11 suspected hijackers worshipped at the mosque.

Al-Awlaki left the US in 2002, eventually travelling to Yemen, but his whereabouts have not been known since he was released from a Yemeni jail last year.

He is on Yemen's most-wanted list, according to Yemeni security officials.