Former Long Island banana mogul Thomas Hoey’s conviction for assaulting his girlfriend was reversed by a Manhattan state appeals court on Tuesday because the trial judge slipped up by excluding Hoey from a key pretrial hearing.

The court said the trial judge — Justice Daniel Fitzgerald — improperly met in chambers with the defense and prosecutors, without Hoey, to hear arguments and rule on the admissibility of evidence relating to his alleged history of assaulting the woman, who didn’t want the case prosecuted.

Fitzgerald eventually allowed the woman’s family to testify about some past alleged abusive treatment, but the Appellate Division First Department said, “Criminal defendants have a fundamental right under the state and federal constitutions to be present at all material stages of trial.”

Hoey, 48, of Garden City, the former owner of Long Island Banana Co., is currently serving consecutive federal sentences of 12 1⁄2 years for drug distribution and obstruction of justice and 5 1⁄2 years for pension fraud at a prison in Berlin, New Hampshire.

In the state case, Hoey was convicted of assaulting his girlfriend in a Manhattan apartment building in 2012 and tampering with evidence for trying to clean blood off the floor after a neighbor called police.

In a second ground for reversal, the appeals court also said that in summations the prosecutor improperly injected her opinion by telling jurors the girlfriend wasn’t called because the district attorney didn’t want to offer perjurious testimony.

advertisement | advertise on newsday

Fitzgerald sentenced Hoey to 1 1⁄3 to 4 years, which would have been served after the federal prison sentences were completed.

Hoey’s appeals lawyer, James Kousouros, said the ruling could dramatically reduce Hoey’s total prison term because the state conviction ratcheted up his federal sentencing guidelines.

If prosecutors pursue the case again, Kousouros said, “We are confident that at retrial Mr. Hoey will prevail.”

A representative for Manhattan District Attorney Cyrus Vance declined to comment on whether Hoey will be retried.