AMMAN, Jordan -- A military court convicted a Jordanian soldier on Monday in the shooting deaths of three U.S. military trainers at a Jordanian air base and sentenced him to life in prison with hard labor.

The defendant had pleaded "not guilty," saying he opened fire because he feared the base was coming under attack.

As he was led out of the courtroom, 1st Sgt. Marik al-Tuwayha said: "I have all the respect for the king, but I was doing my job."

Get Breaking News Delivered to Your Inbox

The parents of one of the slain U.S. soldiers and the father and sister of another sat quietly as the judge announced his ruling to a crowded courtroom.

The three U.S. Army Green Berets were killed Nov. 4, as their convoy waited at the gate to the base. Jordan initially said the Americans triggered the shooting by disobeying entry rules, a claim that was later withdrawn.

The U.S. Embassy said in a statement Monday that the trial "confirmed that the deceased U.S. service members followed all established procedures when accessing the base the day of the incident, as we have noted before."

"We are reassured to see the perpetrator brought to justice," it said.

The victims were 27-year-old Staff Sgt. Matthew C. Lewellen of Kirksville, Missouri; 30-year-old Staff Sgt. Kevin J. McEnroe of Tucson, Arizona; and 27-year-old Staff Sgt. James F. Moriarty of Kerrville, Texas.

Relatives of the slain troops attended parts of the month-long trial in Jordan's capital of Amman.

Some of the family members had criticized Jordan's handling of the case and said the maximum possible sentence of life in prison was not severe enough, calling for the death penalty.

In Jordan, life in prison can mean 20 years, with time off for good behavior.

Earlier this year, a Jordanian soldier who killed seven Israeli schoolgirls in a 1997 shooting rampage was released after 20 years.

Defense attorney Subhi al-Mawas said he would appeal the sentence.