A Libyan man convicted of conspiracy in the 2012 attacks on U.S. facilities in Benghazi that killed a U.S. ambassador and three other Americans was sentenced to 19½ years in prison Thursday by a federal judge in Washington.

A jury in June convicted Mustafa al-Imam, 47, of one count each of conspiracy to provide material support to terrorists and maliciously destroying government property in the overnight attacks that began Sept. 11, 2012, on a U.S. diplomatic mission and nearby CIA post.

Prosecutors declined to retry Imam on 15 other counts that jurors hung on, including murder in the death of J. Christopher Stevens, the first U.S. ambassador killed on duty in nearly 40 years.

As with militia leader Ahmed Abu Khattala, convicted and sentenced in 2018 to 22 years in prison as one of the attacks’ ringleaders, prosecutors argued that although jurors did not convict Imam of murder, a judge could consider the deaths at sentencing if they were a “reasonably foreseeable” consequence of the conspiracy.

U.S. District Judge Christopher R. “Casey” Cooper, who tried both cases, agreed with prosecutors. He found Imam acted as Abu Khattala’s “eyes and ears” in an attack calculated to result in deaths.

“The United States has military bases, diplomatic embassies and other facilities all over the world . . . [with personnel] who are very exposed, and very vulnerable to targeting, as recent events have shown,” Cooper said, alluding to Iran’s Jan. 8 missile strikes against military bases in Iraq and the breach of the U.S. Embassy in Baghdad.

“Anyone contemplating harming them needs to know they will face serious consequences,” Cooper said.

Prosecutors John Cummings and Karen P.W. Seifert said Imam should serve the maximum 15- and 20-year prison sentences his two convictions allowed for back to back, as punishment for “an attack designed to maximize the pain and humiliation it would cause the United States” on the anniversary of the Sept. 11, 2001, terrorist attacks. Cooper agreed to sentence Imam to nearly the maximum, but declined to stack the sentences, saying both counts charged Imam with the same underlying conduct.

Imam’s sentence should be judged by Americans by one question, Cummings said, “Did the court protect me, and send a message to those who would harm me or my loved ones that we are not going to tolerate it?”

Assistant Attorney General for National Security John C. Demers issued a statement after the sentencing: “We have not rested in our efforts to bring to justice those involved in the terrorist attacks on our facilities in Benghazi, which led to the death of four courageous Americans — Tyrone Woods, Sean Smith, Glen Doherty, and Ambassador Christopher Stevens — and we never will.”

Prosecutors cited phone records and witness statements showing Imam accompanied Abu Khattala to the scene and the pair spoke repeatedly. One conversation included an 18-minute call at the height of the attack that involved grenades, automatic weapons and bombs in which Abu Khattala appeared to coordinate actions of about a dozen of his men through Imam.

At Abu Khattala’s direction, Imam also stole a map and phone from the U.S. mission, an act caught on surveillance video, prosecutors said.

Attorneys for Imam asked for a 41-month term, saying there was no evidence he knew or agreed with the assault.

“We are disappointed by the sentence,” said Matthew J. Peed, Imam’s court-appointed attorney. “It was based on allegations the jury did not find. We look forward to our appeal.”

Imam did not address the court.

Imam’s defense said he was a simple convenience shop clerk whom Abu Khattala manipulated to give himself an alibi. Peed said it would not serve justice or deter future attacks to treat every pro-nationalist Libyan as an anti-American terrorist. He also discouraged handing down effective life sentences to every one of the dozens who stormed a compound that Abu Khattala called a foreign “spy base.”

“The victims of this attack do deserve justice, and I hope the government is able to bring to trial the remaining members of Abu Khattala’s special forces if they are still alive,” Peed said. But “an unjust sentence will lead to feelings of resentment that are the very gen­esis of terrorism.”

Abu Khattala was captured by U.S. Special Forces in Libya in June 2017, and his case was seen as a test of detention and interrogation policies developed under the Obama administration to capture terrorism suspects overseas for criminal trial.

Imam’s capture in Libya in a similar U.S. military raid on Oct. 29, 2017, marked the first time President Trump ordered a similar action.

Despite the mixed verdicts in both trials, legal analysts said the hybrid military and civilian operations and prosecutions removed alleged combatants from the battlefield.

On Thursday several relatives of the victims attended the hearing.

Doherty’s brother, Greg Doherty, said he was torn about whether terrorists are better fought on the battlefield or in a court. He called sentencing reductions that give a pass to conspirators a travesty, but said he was consoled by the effective life term given Abu Khattala.

Peter Sullivan, married to Stevens’ sister, had testified that the ambassador was “a man of peace” who worked to pull Libyans together. Sullivan discouraged “a reactionary sentence,” and instead requested a “proactive” one to help Americans working for their country overseas.