The correspondence between the senior Brooklyn judge and the longtime district attorney is remarkable even for the often troubled world of Brooklyn politics. On a near daily basis, the judge advised the district attorney—on how to get re-elected, on how to deal with his own legal problems, and, perhaps most importantly, on how to manage any damage from an investigation into possibly wrongful convictions won by the district attorney's office over the years.

The judge is Barry Kamins, the man who during the correspondence was in charge of all criminal courts in Brooklyn. The district attorney is Charles J. Hynes, who served as the top prosecutor in Brooklyn for 24 years before, despite Kamins's campaign advice, he lost his bid for a seventh term last fall. Their communications became public Monday when the New York City Department of Investigation issued a damning 27-page report into how Hynes financed and conducted his 2013 re-election campaign.

Kamins, who had recently been promoted to an even more senior job in the New York State court system, has been relieved of his duties, and it is possible he will ultimately retire. Hynes could face criminal charges, and the office he once ran could find itself the target of more investigations.

ProPublica has spent more than a year examining the question of prosecutorial misconduct, and much of our focus has been on the office Hynes ran in Brooklyn for more than two decades. Hynes has been accused in one prominent lawsuit of having overseen an office where misconduct was condoned, and ProPublica has indeed found instances in which prosecutors working for Hynes violated their legal obligations but suffered no serious consequences.

The emerging information about Hynes' relationship with Brooklyn's top judge adds to the picture of a judicial system with few checks and balances.

One thing seems certain: No one interested in Brooklyn politics—those newly intrigued or those familiarly appalled—will soon forget the frank 2013 email exchanges between two of the most powerful law enforcement officials in Brooklyn.

"Judge Kamins appears to have, among other things, regularly advised Hynes regarding advantageous political endorsements, provided feedback on Hynes' public statements, assisted Hynes in his preparation for televised debates, and communicated with other individuals on Hynes' behalf regarding campaign-related activity," the report said by way of summary.

Kamins' input could be as mundane as a copyediting suggestion on a campaign announcement or as grave as how Hynes could best deal with a crisis wracking the office during the campaign: the possibility that the district attorney's office had sent innocent people to prison based in part on the flawed work of an apparently rogue police detective.

Those exchanges about wrongful convictions take place in late May 2013, weeks after Hynes had agreed to release a convicted murderer after 23 years in prison because of concerns about the honesty of the detective who had helped make the original case. Hynes, facing an onslaught of unflattering news articles and editorials, had subsequently agreed to have some 50 murder cases involving the detective reviewed by his office. He informed Kamins that he wanted to appoint a panel of purportedly independent legal figures to, in effect, review his office's review.

"I don't agree with a board to 'review' findings," Kamins wrote to Hynes. "If this group should find fault with the work of the office that puts you in a worse situation. What do you do then? Go back and start over? It could be a disaster."

Kamins, in addition to suggesting people to serve on the panel, proposes allowing its members to participate in the actual review.

"That way," he wrote, "the final product will not be subject to further review and will have the appearance of independent judgment."

The Department of Investigation's findings were first reported by the New York Times.

Kamins and Hynes have long been both personal friends and major players in Brooklyn's legal world.

Kamins in the 1970s served in the district attorney's office, later became a defense lawyer, went on to head the New York City Bar Association, and was eventually made a judge. While a defense lawyer, Kamins had been a regular campaign contributor to Hynes, and a New York Times article in 1994 reported that he had benefited from what struck many as a kind of legal patronage: regular, paid appointments to serve as a special prosecutor in cases where Hynes, as district attorney, had a conflict of interest. Kamins has taught at two of the city's better law schools and in the last few months was named by the state's chief judge to serve as head of policy and planning for New York's court system.

A senior New York court official said it did not appear Kamins had broken any laws. His future, then, could well be decided by the Commission on Judicial Conduct, which has the power to remove him from his job and perhaps sanction him further.

"Joe Hynes and Barry Kamins have been friends for 40 years and have talked politics most of that time," said Paul Shechtman, Kamins' lawyer. "And the great bulk of this was Judge Kamins listening to Joe's gripes about a campaign that turned out to be much more closely contested than he ever imagined. But the Judge did nothing to influence the course of any case. He never favored Joe in the courtroom and he never would."

The Department of Investigation, having been quietly alerted to potential misconduct by Hynes and Kamins late last year, found that Hynes had misused hundreds of thousands of dollars of the office's money to pay for his campaign, and had improperly enlisted the help of his senior staff to participate in his re-election effort.

Hynes has not responded publicly to the findings.

One person who knows Kamins well said it was possible the judge still was not cognizant of how serious his misconduct was. Certainly, much about the exchanges with Hynes seems bafflingly casual. They each talked about keeping communications secret, but both used their government email accounts. Hynes even shared his communications with Kamins with other people in his own office.

"You are the new David Garth," Hynes wrote to Kamins in one email, invoking the legendary New York political consultant.

"Yes. I charge very little to be a consultant," Kamins responded, foreseeing a triumph for Hynes and a joyous election night with the district attorney and his wife. "My only request: standing next to you and Pat at the victory speech."

Kamins, the emails make clear, played a role in trying to get a fair hearing and good press for Hynes at The New York Times, the New York Law Journal and other publications. He claimed that he tried to "pump" the president of the Brooklyn Bar Association for information about what might come up in a looming campaign debate Hynes was to have with the man who ultimately defeated him, former federal prosecutor Kenneth Thompson. He even reviewed the opening statement Hynes was to give at the start of one debate with Thompson.

"Very good," Kamins wrote, "except do you want to go negative right away?"

Near the end of the Department of Investigation report, investigators relate two episodes in which Kamins offered actual, concrete legal advice to Hynes—on the merits of a lawsuit brought by a political rival of Hynes to prevent CBS from broadcasting a program featuring the Brooklyn District Attorney's office and on the question of whether a newspaper article that upset Hynes might be libelous.

The report concludes by listing a dozen roughly aspects of the judicial code of conduct that Kamins might have broken.

Joel Rudin, the lawyer who has sued Hynes office for a range of misconduct, is mentioned unflatteringly by Kamins in the emails.

"I've always had a deeply felt regard for Barry Kamins, and it's very painful to see how he completely lost perspective about what he was doing and who he was," Rudin said. "And I feel sorry for him."

It is unclear how long it will take the Commission on Judicial Conduct to review Kamins' behavior.

But one future event Kamins and Hynes jokingly discussed is not apt to take place. In one email, Hynes said he looked forward to the day Kamins would swear him in as a judge.

Kamins wrote back optimistically:

"My fondest wish."

Joaquin Sapien contributed reporting.