Public advocate and Democratic mayoral candidate Bill de Blasio won himself a seat at the table that will decide the fate of the troubled Long Island College Hospital in Brooklyn, a judge has ruled.

De Blasio – who was arrested at a pro-LICH protest in July and used the hospital as part of his campaign platform joins community groups like the Brooklyn Heights and Cobble Hill Associations – whose two neighborhoods the hospital straddles — as interveners in the bitter court fight with State University of New York over who will operate the financially-ailing hospital.

“The Public Advocate’s motion to intervene is granted,” Brooklyn Supreme Court Judge Carolyn Demarest wrote in her decision, which bashes SUNY for reneging on its promise to operate LICH as a nonprofit that serves the community.

Being an intervener is similar to being a plaintiff or defendant in a traditional case. De Blasio will be able to attend all conferences, speak in open court, and present witnesses.

“This community has to have a seat at the table to protect the future of this hospital. We won’t let this become another real estate deal that robs a neighborhood of vital health care,” said de Blasio. “We will keep fighting for a long-term solution that keeps L.I.C.H. open for care.”

In August Judge Demarest revoked SUNY Downstate’s controversial takeover and shutdown of LICH — which includes real estate worth up to a billion dollars — in a bombshell order that slammed the operator’s “sinister purpose to seize its assets and dismantle the hospital.”

The judge had originally signed off on SUNY Downstate’s takeover of the failing Long Island College Hospital in 2011, but today withdrew that approval after SUNY ignored court orders to keep the Cobble Hill medical center open.

Since de Blasio will leave the public advocate post in January, likely incoming public advocate Letitia James will take over the LICH case when she takes office.

Two labor groups that also tried for intervener status were shut down.

“We have the decision and it’s under review,” said SUNY spokesman Bob Bellafiore.