A wannabe terrorist from Long Island was sentenced Tuesday to 13 years in prison by a federal judge who took pity on him because he’s autistic.

Justin Kaliebe, 22, of Bay Shore, faced up to 30 years for trying to join a Yemeni branch of al Qaeda in 2013 to wage jihad against the US.

Long Island federal court Judge Denis Hurley agreed that Kaliebe was “radicalized to the nth degree” but said he has a “malady” and “probably falls somewhere on the autistic scale.”

“I am very sympathetic to this defendant,” said Hurley during the hours-long sentencing proceeding in Central Islip. “Besides from the havoc he intended to cause, he is a very nice young man.”

Before a courtroom packed with relatives and friends, Kaliebe tearfully apologized for turning to radical Islam as a way to escape a childhood of bullying.

“I thought I finally found true friends at the mosque in Bay Shore,” he said about converting to Islam in his early teens. “I have now renounced Islam. I have chosen to be guided by love.”

Kaliebe’s mother audibly wept in court as he added, “I regret every day of my actions. I wish I was in college right now. I wish I could be with my mother and sister right now.”

He begged Hurley not to throw the book at him.

“Please, Judge Hurley, don’t lock me up and throw away the key. Let me have another chance to live my life,” Kaliebe said.

In 2013, Kaliebe pleaded guilty to two counts of attempting to provide material support to terrorists.

He’ll be under 20 years of supervised release once he gets out of prison.

His co-defendant Marcos Alonso Zea was sentenced to 25 years for also plotting to join al Qaeda.