A federal appellate court refused Thursday to throw out the guilty plea of a Brentwood man who tried to join the terrorist group al-Qaida, ruling that despite inadequate instruction from the judge, the man still entered his plea knowingly.

Marcos Alonso Zea, 28, pleaded guilty two years ago in Central Islip to attempting to provide material support to a foreign terrorist organization and to obstruction of justice. U.S. District Judge Sandra Feuerstein sentenced Zea to 25 years in prison.

Zea admitted that he bought a plane ticket to Yemen with the intent of joining al-Qaida and hoped to wage “violent jihad.” But he only got as far as London in January 2012 after British authorities turned him back because he did not have a Yemeni visa.

He was arrested at Kennedy Airport a year later when he tried again to go to Yemen.

In his appeal, Zea said his plea should be vacated because Feuerstein failed to clearly review his “rights to testify, to compel the attendance of witnesses, and have counsel at every stage,” as court rules required.

In an affidavit with his appeal, Zea said that if the judge had “explained these points to me clearly, including all of the rights that I was waiving, I likely would not have pleaded guilty at that time.”

advertisement | advertise on newsday

Although the Second Circuit Court of Appeals panel said Feuerstein should have advised Zea of his rights, it said there is no evidence to suggest Zea didn’t want to plead guilty or was doing so in an uninformed way.

The appellate court noted that Zea signed a written plea agreement that noted all the rights he was waiving, discussed the agreement with his trial lawyer and said in court that he understood all of it.

Still, the appellate court wrote in its decision that it has “adopted a standard of strict adherence” to the rule that trial judges must properly advise all defendants pleading guilty of the rights that they are giving up and must make sure defendants know what they are doing.

The court also wrote that both defense attorneys and prosecutors have a responsibility to make sure judges advise defendants and that they should speak up in court if judges fail to do so.

A spokeswoman for the Eastern District U.S. Attorney’s office declined to comment on the decision. The Federal Public Defender’s Office, which represented Zea on appeal, did not respond to a request for comment.