It could be said that two separate trials are taking place, side by side, these days in Room 8D of the Federal District Court in Brooklyn.

At the actual trial, the United States government is prosecuting Joaquín Guzmán Loera, who is accused of being one of the world’s biggest drug dealers. Widely known as El Chapo, Mr. Guzmán, prosecutors say, earned as much as $14 billion as head of the Sinaloa drug cartel — a fortune he is said to have protected with rampant payoffs and an army of professional assassins.

But at a second trial of sorts, Mr. Guzmán’s lawyers are, in essence, prosecuting the government of Mexico. By their account, the country’s police and politicians not only are corrupt, but also have conspired for years with Mr. Guzmán’s partner, Ismael Zambada García, to target El Chapo in exchange for a flood of bribes.

Judge Brian M. Cogan has been tasked with keeping the first of these trials on track and the second one in check. Given the sensitivities involved and the enormous news media attention, he has conducted much of the proceedings in secret.

It all began on Wednesday last week when the judge held a sidebar conversation with the defense and prosecution to discuss whether Mr. Guzmán’s lawyers should be allowed to pursue their claims that Mr. Zambada was the real mastermind of the cartel. The defense informed the judge that the government’s first main witness, Mr. Zambada’s brother, Jesus Zambada García, would testify, if asked, to a bombshell revelation: He had once been ordered by his brother to bribe the “now incumbent” president of Mexico.

Though the exchange occurred in private, reporters obtained a transcript, and by Friday night, word spread that a witness at the trial of El Chapo was poised to accuse a Mexican president of taking bribes. A complicated game began in which students of Mexican politics tried to divine which president it was from the cryptic comments made in court.

Was it the incumbent, Enrique Peña Nieto?

Or maybe the defense had erred and it was actually the president-elect: Andrés Manuel López Obrador.

When court convened again on Monday, the audience waited in suspense as Mr. Zambada took the stand, blithely spilling secrets of the Sinaloa drug cartel and laying bare the inner workings of Mr. Guzman’s operation. But even though he confessed to startling crimes — admitting, for example, that he personally paid $300,000 in bribes a month, for years — he never mentioned anything about bribing a Mexican president.

Then on Monday night, only hours before Mr. Zambada was to spend his final day in court, the government filed a mysterious memo that, according to its title, was designed “to preclude cross-examination.” The memo, submitted under seal, outraged the defense. It also left those in the courtroom wondering if the tale of a corrupted president would indeed be told.

As soon as court was back in session on Tuesday, Judge Cogan discussed the secret memo at a second sidebar conference — which was itself conducted in secret. The subject was apparently so sensitive that he immediately placed its transcript under seal.

It was only after the sidebar ended that Judge Cogan gave a vague explanation about what was going on.

Speaking from the bench, he said that he agreed with the prosecutors and would limit the questions that Mr. Guzmán’s lawyers could ask Mr. Zambada on cross-examination. He also said that whatever might be learned from a broader line of inquiry did not outweigh “protecting individuals and entities” who were not directly involved in the case and “who would face embarrassment” if Mr. Zambada were allowed to testify without restraint.

Judge Cogan never identified those “individuals and entities,” and because he sealed the transcript, the government and the defense could not discuss them. Who they were — and why they stood to face embarrassment — remains another secret.

In court on Tuesday, Mr. Zambada did name one of Mexico’s top law enforcement officials, Genaro García Luna, as someone who took bribes. He said that on two occasions he met Mr. García Luna in a restaurant and each time gave him a briefcase stuffed with at least $3 million in cash.

Mexico has long been plagued by troubles with corruption, and some in the country were not at all surprised that tales of graft were emerging, thousands of miles away, at El Chapo’s trial in Brooklyn.

“The world might be shocked, but here, for us, this is old news,” said Fernanda Hernández, 23, a secretary from Mexico City. “To learn the inner workings of corruption at the highest level is something that for some reason feels rather obvious to us.”

All the secrecy was consistent with the way the Guzmán case has been handled from the start. In the past several months, the prosecution has sent more than a dozen secret letters to Judge Cogan. Many of its pretrial arguments were made in sealed or redacted motions.

With the judge’s permission, the prosecutors have even barred courtroom artists from sketching the faces of some witnesses in an attempt to ensure their safety.

To justify these measures, the government has claimed that Mr. Guzmán — who twice escaped from prison and prosecutors say ordered the deaths of thousands in his homeland — is a singular security risk. A certain level of concealment is required, the prosecutors have said, to safeguard both the witnesses and the general public.

Well before the trial began, Mr. Guzmán’s lawyers complained about the secrecy. They criticized the government’s repeated use of private letters to the judge, which they are not allowed to see, saying the missives hindered their ability to mount an adequate defense. More than once, the lawyers have described the case as “a trial by ambush.”

Despite their arguments, however, the secrecy has continued.

On Tuesday night, a few hours after court let out, the prosecutors filed another memo to Judge Cogan. Not surprisingly, it was under seal.

Correction:Nov. 21, 2018

An earlier version of this article misstated the given name of the president of Mexico. He is Enrique Peña Nieto, not Ernesto.

Paulina Villegas contributed reporting.

A version of this article appears in print on , Section A, Page 24 of the New York edition with the headline: Trial of El Chapo Is in Public. Why Are So Many Parts of It Secret?. Order Reprints | Today’s Paper | Subscribe