Hundreds of unarmed soldiers, some about to deploy to Afghanistan, were waiting inside a building for vaccines and routine checkups when a fellow soldier walked inside with two handguns and enough ammunition to commit one of the worst mass shootings in American history.

Maj. Nidal Malik Hasan climbed onto a desk and shouted “Allahu Akbar!” — an Arabic phrase meaning “God is great!” Then he opened fire, pausing only to reload.

Hasan doesn’t deny that he carried out the November 2009 rampage at Fort Hood, Texas, that left 13 people dead and more than 30 others wounded. There are dozens of witnesses who saw it happen. Military law prohibits him from entering a guilty plea because authorities are seeking the death penalty. But if he is convicted and sentenced to death in a trial that starts Tuesday, there are likely years, if not decades, of appeals ahead.

He may never make it to the death chamber at all.

While the Hasan case is unusually complex, experts also say the military justice system is unaccustomed to dealing with death penalty cases and has struggled to avoid overturned sentences.

Eleven of the 16 death sentences handed down by military juries in the last 30 years have been overturned, according to an academic study and court records. No active-duty soldier has been executed since 1961.

A reversed verdict or sentence on appeal in the Hasan case would be a fiasco for prosecutors and the Army. That’s one reason why prosecutors and the military judge have been deliberate leading up to trial, said Geoffrey Corn, a professor at the South Texas College of Law and former military lawyer.

“The public looks and says, ‘This is an obviously guilty defendant. What’s so hard about this?’” Corn said. “What seems so simple is in fact relatively complicated.”

Hasan is charged with 13 specifications of premeditated murder and 32 specifications of attempted premeditated murder. Thirteen officers from around the country who hold Hasan’s rank or higher will serve on the jury for a trial that will likely last one month and probably longer. They must be unanimous to convict Hasan of murder and sentence him to death. Three-quarters of the panel must vote for an attempted murder conviction.

The jury will likely hear from victims and relatives of the dead. A handful of victims still carry bullet fragments in their bodies. Others have nightmares.

“It never goes away — being upset that it’s taken so long for this trial to come,” said Staff Sgt. Alonzo Lunsford, who was shot in the head, stomach and upper body. “So now’s the day of reckoning, which is positive — very positive.”

The trial’s start has been delayed over and over, often due to requests from Hasan. Any of the hundreds of decisions large or small could be fair game on appeal. The entire record will be scrutinized by military appeals courts that have overturned most of the death sentences they’ve considered.

“A good prosecutor, in military parlance, would be foolish to fight only the close battle,” Corn said. “He’s got to fight the close battle and the future battle. And the future battle is the appellate record.”

Hasan has twice dismissed his lawyers and now plans to represent himself at trial. He’s suggested he wants to argue the killings were in “defense of others” — namely, members of the Taliban fighting Americans in Afghanistan. The trial judge, Col. Tara Osborn, has so far denied that strategy.

Hasan has grown a beard while in custody that he says expresses his Muslim faith, but violates military rules on decorum. After a military judge ordered him forcibly shaved, an appeals court stayed that order and took another judge off the case.

The last man executed in the military system was Pvt. John Bennett, hanged in 1961 for raping an 11-year-old girl. Five men are on the military death row at Fort Leavenworth, Kan., but none are close to being executed.

An inmate was taken off death row just last year. Kenneth Parker was condemned for killing two fellow Marines in North Carolina, including Lance Cpl. Rodney Page. But Parker was given life without parole last September by an appeals court. The court found his trial judge should have not allowed him to be tried for both murders at the same time, nor should the judge have allowed testimony that the appeals court said was irrelevant to the crimes.

Parker’s accomplice in the killings, Wade Walker, was also sentenced to death, only for the sentence to be overturned.

Examples abound of other death sentences set aside. They include William Kreutzer Jr., who killed one soldier and wounded 18 others in a 1995 shooting spree at Fort Bragg, N.C.; James T. Murphy, who killed his wife in Germany with a hammer; and Melvin Turner, who killed his 11-month-old daughter with a razor blade.

Part of the problem, experts say, is that death penalty cases are rare in military courts.

A study in the Journal of Criminal Law & Criminology identified just 41 cases between 1984 and 2005 where a defendant faced a court-martial on a capital charge. Meanwhile, more than 500 people have been executed since 1982 in the civilian system in Texas, the nation’s most active death-penalty state.