On the night of June 25th, the Queens County Democratic Party appeared to suffer not one, but two, grievous blows. Tiffany Cabán, the democratic socialist upstart, led Melinda Katz, the Queens borough president, by more than 1,100 votes in the historic primary for district attorney.

And a little known attorney named Wyatt Gibbons, a friend of the party for decades, was soundly defeated.

Both are now back from the dead. After a weeks-long recount and a failed legal challenge, Katz is on her way to becoming Queens’ next district attorney. Gibbons, in an even more unlikely turn of events, is getting the judgeship he wanted: Democratic Party insiders on Thursday night elevated the recently defeated Gibbons to a State Supreme Court seat, which comes with higher pay, a longer term, and the ability to serve another six years before mandatory retirement than the civil seat he was running for.

The maneuver, arguably a rebuke of the voters who chose not to nominate Gibbons to another term in the June 25th primary, is both audacious and rare. Queens, unlike Brooklyn and Manhattan, has had virtually no contested primaries for civil court judge. The last defeat, according to Democratic consultant and longtime elections watcher Jerry Skurnik, was in 1977.

Gibbons battled back tears on Thursday as he accepted the nomination to the State Supreme Court seat, one of six vacancies the party filled during a judicial convention held at Antun’s, the tony Queens Village catering hall that hosts almost all Queens Democratic functions. “A really smart guy once said, all’s well that ends well,” Gibbons said. “What a long, strange trip it’s been.”

The judicial convention, held once a year, is a reminder that for all the ways municipal politics has radically transformed over the last few years, certain elements remain unchanged. The convention was a highly scripted affair that lasted a little more than an hour, as delegates munched on brownies and chocolate chip cookies in a large ballroom, never dissenting from their county leader, Congressman Gregory Meeks. The vibe evoked a giddy family reunion.

Meeks told Gothamist that he, in consultation with other party officials, decided to elevate Gibbons to the Supreme Court, which carries a 14-year term, because he trusted his legal acumen. He also admitted the county organization was too preoccupied with trying to elect Katz to offer much help to Gibbons, who had a negligible campaign presence leading into the primary.

“He was chosen as a nominee because of his skills, his ability, his quality,” Meeks said. “We did not, I did not, do all that we could to make he sure that he was out there. We were so focused on the district attorney’s race and I think the voters will look at his record and what he did on the bench and say he was a quality jurist.”

Gibbons, like every judge nominated yesterday, has a long history in Queens Democratic politics. He is a member of the Jefferson Democratic Club in Bayside. A Democratic district leader and former president of the old Board of Education, Carol Gresser, nominated Gibbons, along with his local assemblymember, Edward Braunstein. A graduate of St. John’s Law School, known as a feeder school into the Queens DA’s office under the late Richard Brown, Gibbons started his career trying cases in the Special Victims Bureau.

Speaking with Gothamist after he was formally nominated, Gibbons said he had been on a “surreal journey” over the last few weeks.

“I’m so happy to be in this position. One door closes and another door opens,” he said.

Pressed for further details about the nomination decision, Gibbons only smiled.

“You’ll have to speak to county, they took care of me,” he said, walking away.

Gibbons’s turnaround was made possible, in part, by judicial delegates who are elected in Democratic primaries, serving single, annual terms without any limits. Many of them are either party insiders or Queens elected officials. Primaries for judicial delegates in Queens are almost unheard of. On Thursday night, nearly 200 delegates were present to vote.

Since Supreme Court judges do not compete in open primaries—judicial conventions produce nominees—party leadership has almost total say over who gets a promotion and who doesn’t. In overwhelmingly Democratic Queens, these judges compete in pro forma general elections against typically nonexistent Republicans.

The delegates, however, arguably matter less than the Democratic district leaders—they can also be delegates—who formally nominate the judges. Without a district leader nomination, a judge goes nowhere. Once a leader rises to nominate a judge, the delegates unanimously confirm them with a voice vote. The district leaders act at the direction of the party leadership.

Just about every judge thanked their local district leaders. One, Donna-Marie Golia, credited Joe Crowley, the congressman and party boss defeated by Alexandria Ocasio-Cortez, and the late Tom Manton, Crowley’s predecessor and mentor, with launching her judicial career. Another, Phillip Hom, was a high school and college classmate of State Senator John Liu, who is also a Democratic district leader.

Judicial candidates are known to regularly contribute campaign cash to the Queens Democratic Party’s account. Decades ago, specific prices were even put on Supreme Court judgeships. One party boss, Matty Troy, recalled the “going rate” for a prized judgeship was $75,000.

Almost every judicial nominee personally thanked Gerard Sweeney, Michael Reich, and Frank Bolz for their Supreme Court seats. The three lawyers have effectively controlled the Queens Democratic Party for more than 30 years, enriching themselves in Surrogate’s Court and, occasionally, off home foreclosures. Most recently, they served as pro bono lawyers for Katz during the recount and subsequent court case. Reich and Bolz sat quietly at the dais during the convention.

Katz herself arrived to rapturous applause and addressed the delegates. Though a district attorney, in theory, must be independent of the local political apparatus in order to prosecute potential political corruption cases, Katz has happily rubbed elbows with the party leaders who forcefully backed her campaign.

“I can’t let this moment go without talking about the amazing representation we had in court,” Katz said, applause again breaking out. “The expertise of Frank Bolz and Gerry Sweeney and Mike Reich and everyone who was helping, counting the votes and volunteering in the Board of Elections—let me thank you from the bottom of my heart for bringing that expertise and making sure that we won by the law and by good government.”

Correction: This story originally categorized Gibbons as a civil court judge, when he is in fact an attorney.