FORT HOOD, TEXAS—A military court on Wednesday sentenced Nidal Hasan to death for the 2009 shooting rampage at Fort Hood, giving the U.S. Army psychiatrist a path to the martyrdom he seemed to want in the attack on unarmed fellow soldiers.

The U.S.-born Muslim has said he acted to protect Islamic insurgents abroad from American aggression, and he never denied being the gunman.

He acknowledged to the jury that he pulled the trigger in a crowded waiting room where troops were getting final medical checkups before deploying to Iraq and Afghanistan. Thireteen people were killed and more than 30 wounded.

It was the worst ever attack on a U.S. military base.

The same jurors who convicted Hasan last week had two options: agree unanimously that Hasan should die or watch the 42-year-old get an automatic sentence of life in prison with no chance of parole.

Hasan could become the first U.S. soldier executed in more than half a century. But because the military justice system requires a lengthy appeals process, years or even decades could pass before he is put to death.

The lead prosecutor assured jurors that Hasan would “never be a martyr” despite his attempt to tie the attack to religion.

“He is a criminal. He is a cold-blooded murderer,” Col. Mike Mulligan said Wednesday in his final plea for a rare military death sentence.

For nearly four years, the federal government has sought to execute Hasan, believing that any sentence short of a lethal injection would deny justice to the families of the dead and the survivors.

Hasan has seemed content to go to the death chamber for his beliefs. He fired his own attorneys to represent himself and barely put up a defence during his trial.

He was never allowed to argue in front of the jury that the shooting was necessary to protect Islamic and Taliban leaders from U.S. troops. During the trial, Hasan leaked documents to journalists that revealed him telling military mental health workers in 2010 that he could “still be a martyr” if executed.

All but one of the dead were soldiers, including a pregnant private who curled on the floor and pleaded for her baby’s life.

The attack ended only when Hasan was shot in the back by an officer responding to the shooting. Hasan is now paralyzed from the waist down.

Death sentences are rare in the military, which has just five other prisoners on death row. The cases trigger a long appeals process. And the president must give final authorization before any service member is executed. No U.S. soldier has been executed since 1961.