A Long Island man functioned “with a diminished capacity,” exhibited the maturity of a 13-year-old and didn’t grasp the magnitude of his actions when he was charged with terrorism offenses, a forensic psychiatrist testified Friday.

Justin Kaliebe, 21, was born with a condition that delayed his physical development, lived in a “chaotic” home that led to depression and showed symptoms of Asperger syndrome by his deep obsession with Islam and other subjects, Dr. Alexander Bardey said in U.S. District Court in Central Islip.

“At the time of the offense, he was suffering from various medical and psychiatric disorders,” Bardey said.

Bardey, who evaluated Kaliebe in 2014, was one of two witnesses called on the final day of defense testimony at a pre-sentencing hearing. Kaliebe’s attorney, Anthony La Pinta of Hauppauge, is hoping to reduce his client’s prison term by presenting possible mitigating circumstances.

Kaliebe, of Bay Shore and Babylon, was arrested at Kennedy Airport in January 2013 as he was about to board a flight to Oman on his way to Yemen, where he said he was attempting to join an al-Qaida affiliate.

In February 2013, the then-18-year-old pleaded guilty to charges including attempting to provide material support to a terrorist organization. He faces up to 30 years in prison.

At one point, he told an undercover agent who tried to talk to him about alternatives to violent jihad that “the only way out is martyrdom,” according to a federal transcript.

In court Friday, La Pinta played snippets of Kaliebe’s recorded conversations with the undercover agent, who befriended Kaliebe at the Masjid Darul Qur’an mosque in Bay Shore. At one point, Kaliebe told the agent “I don’t have a lot of resources” — a reference to joining al-Qaida. The agent replies: “Brother, it’s all about the heart.”

Bilal Hito, 30, a member of the mosque, testified that Kaliebe was a “timid” high school student when he joined the mosque in 2011 but soon became popular.

advertisement | advertise on newsday

“He was smiling, he was doing more talking,” said Hito of West Islip.

Bardey testified that Kaliebe told him he wanted to go to the Middle East to reclaim land and join “an army to fight a war,” not hurt innocent people.

During cross-examination, Bardey told Assistant U.S. Attorney Michael Canty he was aware of the recordings with the undercover agent but didn’t review them until after making his diagnosis.

Prosecutors will present their witnesses — a medical expert and federal terrorism agent — on July 19.