WASHINGTON — He has spent months inside his Park Avenue apartment glued to cable news, his legal bills growing and federal prosecutors amassing evidence against him they would use as leverage.
He watched his onetime friend and former boss, now the president of the United States, smear him on Twitter and make vague, public threats about his family.
His work for Donald J. Trump, and the lies he told about it, is sending him to prison for years.
On Tuesday, his law license was revoked.
On Wednesday, Michael D. Cohen exacted his revenge.
It was a nasty, public breakup of a New York relationship forged over a decade that — as Mr. Cohen and associates have described it — was a mix of the bond between a father and son, the professional distance of a lawyer and client, and the blind loyalty of a mafia henchman to a crime boss.
“I regret the day I said ‘yes’ to Mr. Trump,” Mr. Cohen told a packed hearing of the House Oversight Committee. “I regret all the help and support I gave him along the way.”
During a morning of lurid testimony, the president’s once-loyal lawyer and fixer gave an accounting under oath of his years of service to Mr. Trump. He recalled shady business deals and racist comments, and spoke in devastating, uncomfortable detail about his private conversations with the man he had idolized.
He was Mr. Trump’s enforcer, a role he once seemed to relish.
“If somebody does something Mr. Trump doesn’t like, I do everything in my power to resolve it to Mr. Trump’s benefit,” he told an interviewer in 2011. “If you do something wrong, I’m going to come at you, grab you by the neck, and I’m not going to let you go until I’m finished.”
More recently, after Mr. Cohen agreed to tell prosecutors about hush-money payments before the 2016 election, it was the president’s turn to use a mafioso’s description of his formerly loyal aide. He called him a “rat.”
Such was the vernacular the two men honed over years spent navigating gritty but potentially lucrative New York industries — construction, real estate and taxi cabs.
On the day that Mr. Cohen was the star witness in a congressional hearing devised to exhume the president’s past, Mr. Trump was thousands of miles away — preparing for a summit meeting with North Korea’s leader he was hoping would lend gravitas to his embattled presidency, and distract from what was taking place back home.
For Mr. Cohen, a man who once walked the hallways of the Trump Organization with a pistol strapped to his ankle and seemed to bask in Mr. Trump’s reflected glory, Wednesday was a moment to absorb the light.
“Michael would describe it as being something akin to a cult,” said Donny Deutsch, the advertising executive and friend of Mr. Cohen. “Michael got sucked into it. And his life is in shambles because of it. And he’s the first one to say that.
The relationship between the two men began in the way that many of Mr. Trump’s relationship’s do: with an act of fealty.
In 2006, residents of Trump World Plaza — a gleaming glass tower near the United Nations — were pushing to strip Mr. Trump’s name from the building and take control over the building’s management.
Mr. Cohen, a former personal injury lawyer who had made millions in the New York City taxi cab business, intervened after Mr. Trump’s son Donald Jr. asked for help. Mr. Cohen had already bought several condominiums in Trump buildings, persuaded family and friends to do the same, and had twice read Mr. Trump’s book “The Art of the Deal.” He helped Mr. Trump put down the East Side rebellion, orchestrating a coup that removed the revolting tenants from the condominium board. Mr. Trump took notice.
In some ways, it was an unequal relationship between two men of different ages, different upbringings and vastly different financial circumstances. Mr. Cohen, the son of a Holocaust survivor, was just 40 years old when he began working for the much older Mr. Trump — the son of a real estate magnate who would inherit millions of dollars of his father’s money.
But Mr. Cohen had a comfortable upbringing in Lawrence, on Long Island, just 13 miles from the house in Queens where Mr. Trump had been raised. And like his future boss, Mr. Cohen combined raw business savvy with help from a family member — in his case, his father-in-law — to make a mark in New York’s outer boroughs.
Mr. Cohen was soon a Trump Organization employee, put in charge of disparate elements of Mr. Trump’s business empire. In 2008, he became chief operating officer of Affliction Entertainment, a venture started by Mr. Trump to bring mixed martial arts fights to a pay-per-view audience.
“I’m nearly speechless knowing Mr. Trump and Affliction have the trust in me for an event that features the greatest assembly of M.M.A. fighters for one show in M.M.A. history,” Mr. Cohen said in a news release announcing his new position, adding that the coming event was “like having Ali, Frazier, Tyson, Holyfield and other top heavyweights all on the same boxing card.”
Working for Mr. Trump, he told lawmakers on Wednesday, was “intoxicating.”
“When you were in his presence,” he said, “you felt like you were involved in something greater than yourself — that you were somehow changing the world.”
He tried to appeal to his boss by embodying the qualities that Mr. Trump had once admired in his own mentor, Roy Cohn. A Bronx-born lawyer, Mr. Cohn rose to prominence working for Senator Joseph McCarthy’s anti-Communist crusade and then spent years as Mr. Trump’s lawyer. Like Mr. Cohen, he was disbarred for unethical conduct.
“Roy was brutal, but he was a very loyal guy,” Mr. Trump once told a biographer. “He brutalized for you.”
Over time he learned how Mr. Trump liked to do business.
“He doesn’t give you questions, he doesn’t give you orders,” he said on Wednesday. “He speaks in code, and I understand the code because I’ve been around him for a decade.”
Shunted to the sidelines
In 2011 Mr. Cohen began scouting prospects for another brawl, a possible presidential run by Mr. Trump in 2012. He traveled to Iowa and accompanied Mr. Trump to a speech at the Conservative Political Action Committee, where he acted like a bar bouncer keeping reporters away from his celebrity boss. Mr. Cohen set up a website called ShouldTrumpRun.org.
He didn’t. But almost immediately after the presidential race was over, Mr. Cohen began compiling information for his boss for the next time. He kept a thick binder on his desk at Trump Tower packed with information about filing deadlines in different states for the 2016 election and other campaign minutiae.
But he was shunted to the sidelines when the campaign began, prohibited by Mr. Trump’s children and other political operatives from making day-to-day campaign decisions. He pursued other business ventures for Mr. Trump, including the ambitious idea of building the tallest skyscraper in Moscow emblazoned with the Trump name.
Trying to gain access to influential figures in Moscow, Mr. Cohen turned to Felix Sater, a Russian immigrant, former felon and F.B.I. informant who had helped Mr. Trump with other development deals and had explored various ventures in Russia.
This effort became a central focus of the investigation by Robert S. Mueller III, the special counsel, who is examining Russia’s attempts to sabotage the 2016 election and any role Mr. Trump’s advisers played in coordinating with Moscow. And the lies he told about the negotiations put him in even more legal jeopardy.
On Wednesday, he apologized to lawmakers for lying to a different congressional panel in 2017, when he said that the Trump Tower Moscow negotiations ended in January 2016, before the first presidential primaries. In fact, they continued for months longer.
“To be clear,” he said, “Mr. Trump knew of and directed the Trump Moscow negotiations throughout the campaign and lied about it. He lied about it because he never expected to win. He also lied about it because he stood to make hundreds of millions of dollars on the Moscow real estate project.”
“And so I lied about it, too,” he added.
After he won the election, Mr. Trump brought many of his longtime confidants to the White House, but Mr. Cohen was left behind. He was disappointed but remained a loyal backbencher, raising money for Mr. Trump’s re-election fund and publicly attacking celebrities like Snoop Dogg and Johnny Depp for their anti-Trump comments.
Republicans at Wednesday’s hearing tried to cast Mr. Cohen as an embittered former aide trying to get payback for being excluded from a White House job. On Twitter, Mr. Trump’s son Eric said that Mr. Cohen was known within the campaign to be seeking a job.
Mr. Cohen has insisted over the past two years — and did again on Wednesday — that he never had any interest in moving to Washington, uprooting his family and giving up his job as Mr. Trump’s personal lawyer. He said that Mr. Trump had wanted him for a White House job, and was upset when it did not work out.
Regardless of the actual circumstances, Mr. Cohen’s absence from the administration created a distance between Mr. Cohen and Mr. Trump that would become a chasm.
Implicating the boss
When F.B.I. agents raided Mr. Cohen’s office and apartment last April, carting off years of business records, emails and other documents, Mr. Cohen relied on his first instinct — he would not flip.
He took at least one call from Mr. Trump, who urged him to stay strong. His lawyers strategized with the president’s, and Mr. Trump praised him and insisted his former fixer and lawyer would never cooperate with prosecutors.
That would change by July, as his legal problems mounted and his friends urged him not to take a fall for Mr. Trump. He changed his Twitter bio page, removing any mention of being Mr. Trump’s personal lawyer, a move people close to him said was deliberate signal of his independence.
Around that time, officials at Mr. Trump’s company began to balk at paying some of Mr. Cohen’s legal fees.
He pleaded guilty in August to financial crimes, and in his guilty plea he implicated his former boss in a scheme to pay hush money to two women before the 2016 election.
It was an extraordinary turn for a once devoted soldier — a decision that Mr. Cohen on Wednesday described as a catharsis.
“I have lied, but I am not a liar. I have done bad things, but I am not a bad man,” he said before a hushed room.
“I have fixed things. But I am no longer your fixer, Mr. Trump.”