US President Donald Trump's personal lawyer was forced to reveal in a New York federal court that Fox News personality Sean Hannity, one of Mr Trump's most ardent defenders, was also on his client list.
Michael Cohen disclosed Mr Hannity's name through one of his own lawyers at the order of the judge.
Stormy Daniels, an adult-film actress who claims to have had a sexual encounter with Trump, watched from the public gallery.
Ms Daniels, in a separate civil case, is fighting a 2016 non-disclosure agreement arranged by Mr Cohen in which she got $130,000 to stop her from discussing her claim she had sex with Mr Trump a decade prior, something the president has denied.
Mr Hannity said that he had never paid for Mr Cohen's services or been represented by him, but had sought confidential legal advice from him.
The conservative host often uses his weeknight broadcast on Fox News to defend the president against what he sees as biased attacks by the media.
Sometimes Mr Trump praises Mr Hannity in return.
Big show tonight on @seanhannity! 9:00 P.M. on @FoxNews
— Donald J. Trump (@realDonaldTrump) April 12, 2018
Mr Cohen was in court to ask the judge to limit the ability of federal prosecutors to review documents seized from his offices and home last week as part of a criminal investigation, which stems in part from a probe into possible collusion between Mr Trump's presidential campaign and Russia.
The Russia investigation has frustrated the White House as it has spread to enfold some of Mr Trump's closest confidantes.
Judge Kimba Wood spent more than two-and-a-half hours listening to arguments by Mr Cohen's lawyers, prosecutors from the US attorney's office in Manhattan and a lawyer representing Mr Trump in the hearing. She is expected to rule later.
She ordered prosecutors to give Mr Cohen's lawyers a copy of the seized materials before the next hearing.
The unexpected naming of Mr Hannity made him the latest media personality to be drawn into the investigation's cast of unlikely supporting characters.
Ms Daniels, whose real name is Stephanie Clifford, sat with her lawyer, Michael Avenatti, who told reporters they were there to help ensure protection for the integrity of the seized documents, some of which they believe pertain to the Daniels agreement.
Mr Cohen has argued that some of the documents and data seized from him under a warrant are protected by attorney-client privilege or otherwise unconnected to the investigation.
But Judge Wood said she would still need the names of those other clients, and rejected his efforts to mask the identity of Mr Hannity, a client Mr Cohen had said wanted to avoid publicity.
"I understand if he doesn't want his name out there, but that's not enough under the law," Judge Wood said, before ordering the name disclosed.
After his identity was revealed, Mr Hannity said on his syndicated radio show that he and Mr Cohen "have occasionally had brief discussions about legal questions about which I wanted his input and his perspective."
He assumed those discussions were covered by attorney-client privilege, he said on the show, which Fox says reaches more than 13 million listeners. In a later post on Twitter, he said the advice "dealt almost exclusively about real estate."
Legal advice can be considered privileged even if given by a lawyer for free.
Mr Hannity told his viewers on 9 April that the raid on Mr Cohen was an effort by federal investigators to wrongly impeach the president. He never mentioned his association with Mr Cohen during the broadcast.
Mr Cohen has asked the court to give his own lawyers the first look at the seized materials so they can identify documents that are protected by attorney-client privilege.
Failing that, they want the court to appoint an independent official known as a special master, a role typically filled by a lawyer, to go through the records and decide what prosecutors can see.
But prosecutors want the documents to be reviewed for attorney-client privilege by a "taint team" of lawyers within their own office, who would be walled off from the main prosecution team.