A Libyan militant was sentenced on Thursday to more than 19 years in prison by a federal judge for his role in the 2012 Benghazi attacks that killed four Americans, including the United States ambassador.

The militant, Mustafa al-Imam, was convicted by a jury last year of conspiring to provide material support to the terrorists who were responsible for the siege on the main diplomatic mission and a nearby C.I.A. annex.

During the trial in United States District Court in Washington last spring, the jurors also convicted Mr. al-Imam of destroying the complex and endangering lives, but deadlocked on murder charges.

Mr. al-Imam, 47, was the second person sentenced in the Sept. 11, 2012, attack, which became the subject of a contentious congressional inquiry sought by Republican critics of the Obama administration and Hillary Clinton, the secretary of state at the time of the siege.