BANGOR, Maine — A Hampden man who already has served time for writing a threatening letter to Gov. Paul LePage was sentenced Thursday in federal court to two years and nine months behind bars for threatening to kill President Barack Obama.

Assistant U.S. Attorney James Moore, who prosecuted the case, said the letter containing the threat was addressed to the president and placed in the outgoing mail by Dunn while he was an inmate at the Piscataquis County Jail in Dover-Foxcroft.

U.S. District Judge John Woodcock ordered that Dunn be imprisoned for 33 months for threatening the president. The sentence will be served after Dunn completes his state drug trafficking sentence, Moore said Thursday.

“Public officials must be able to carry out their duties without being exposed to threats against their life,” U.S. Attorney Thomas E. Delahanty II said Thursday.

Woodcock also ordered that three years of supervised release be tacked on to the end of Dunn’s federal prison term, Moore said.

“Given Mr. Dunn’s mental health and criminal history and the seriousness of the crime, I think it’s an appropriate sentence,” the assistant U.S. attorney said.

Dunn’s mother, Philomena Gordon of Bingham, has said her son is mentally disabled and suffers from the effects of Marfan syndrome, and should be under supervised medical and psychiatric care, not behind bars.

Dunn’s threatening letter to LePage, which was signed by him and graphically detailed how he planned to kill the governor, also was written while Dunn was at the Piscataquis County Jail. He was sentenced in June 2011 to 60 days in jail for terrorizing the governor, a sentence that he served concurrently with the beginning of his three-year sentence for drug trafficking.

The investigation in the case that concluded Thursday was conducted jointly by the U.S. Secret Service, the Piscataquis County Sheriff’s Office and the Maine State Police.