A Brooklyn federal judge on Thursday ruled that Long Island terrorist-turned-informant Bryant Vinas can be released in three months, after the former al-Qaida operative who planned and then exposed a plot to attack the Long Island Rail Road said there was “no excuse” for his actions.

“I would like to turn a bad thing into a good thing,” the ponytailed former jihadi with black-rimmed glasses said as he told U.S. District Judge Nicholas Garaufis that his career ambition was to work as a counterterrorism expert, with construction work as a fallback.

Vinas, 34, formerly of Patchogue, journeyed to Afghanistan and Pakistan in 2007. After joining al-Qaida, he was captured and began cooperating with the United States in late 2008. He has been in solitary confinement for more than eight years, and Garaufis sentenced him to “time served,” plus 90 days.

Prosecutors lauded his assistance, crediting him with providing “unparalleled” insights into al-Qaida recruitment, operations and leadership. Garaufis seconded that conclusion, saying his assistance and the risk of retaliation by terrorists had to be rewarded with a light sentence.

“It is quite clear Mr. Vinas has put himself in grave danger to provide assistance to the United States,” the judge said. “Mr. Vinas will continue to bear this risk for the rest of his life.”

Although he will be released soon, the judge also placed Vinas on lifetime probation supervision, requiring him to get mental health counseling, permit searches of his computers and residence, stay employed, and continue to cooperate.

advertisement | advertise on newsday

Prosecutors said that after eight years, Vinas has become less open and communicative with them, so they weren’t sure what kind of future risk he might pose.

But the judge deflected the concern. “No one has a crystal ball,” Garaufis said. “ . . . I am cautiously optimistic Mr. Vinas has learned the error of his ways and will never again commit a crime of this nature.”

While he was overseas, Vinas received weapons training, at one point volunteered to be a suicide bomber; aided in attempted mortar and rocket attacks on U.S. bases; and brainstormed plots on both the LIRR and a Walmart, using a television packed with explosives.

He pleaded guilty in January 2009 to conspiracy to murder U.S. nationals, providing material support to a terrorist organization and receiving military training. He faced a maximum sentence of life, and federal guidelines called for at least 30 years in prison.

Vinas’ father and sister attended the sentencing but declined to speak to reporters afterward. As a federal informant, Vinas is entitled to participate in the witness security program, and his lawyer signaled that he would.

“Appropriate security arrangements are being made,” defense attorney Steve Zissou said.

According to friends and court filings, Vinas was adrift after high school, he washed out of the Army and was drawn to jihad over the internet.

But the sentencing added little to that picture. Vinas sent no letter to Garaufis and offered no explanations as to why he became a terrorist or why he changed.

advertisement | advertise on newsday

He did say he hoped to get back surgery when released, and told Garaufis: “I’d like to express my deepest apology for my actions. . . . To say I’m remorseful would be an understatement.”

When the judge imposed the sentence, Vinas showed no obvious emotion aside from shaking hands and embracing his attorneys.

“He was relieved and he was grateful,” said attorney Michael Bachrach, who spoke to him afterward, “and he was looking forward to his new life.”