Deryke Matthew Pfeifer and President Barack Obama. (Photos/DCSO and AP )

MONTGOMERY, Ala. (AP) — A federal judge says the government can force an Alabama man who threatened President Barack Obama to take medication to determine if he’s competent to stand trial.

U.S. District Judge Myron Thompson on Wednesday granted a request to order medication for Deryke Matthew Pfeifer of Ozark. Pfeifer can be forced to take the medication if he doesn’t comply.

Pfeifer was arrested in July 2014 on charges of threatening Obama in calls to the Federal Protective Service and in online videos. He was angry with Obama for condoning same-sex marriage.

The judge says several mental health professionals have evaluated Pfeiffer and determined he has a rare form of a delusional disorder. Thompson wrote in his ruling that medication could be Pfeifer’s best chance to avoid being indefinitely institutionalized.