For years, a joke among Trump Tower employees was that the boss was like Manhattan’s First Avenue, where the traffic goes only one way.

That one-sidedness has always been at the heart of President Trump’s relationship with his longtime lawyer and fixer, Michael D. Cohen, who has said he would “take a bullet” for Mr. Trump. For years Mr. Trump treated Mr. Cohen poorly, with gratuitous insults, dismissive statements and, at least twice, threats of being fired, according to interviews with a half-dozen people familiar with their relationship.

“Donald goes out of his way to treat him like garbage,” said Roger J. Stone Jr., Mr. Trump’s informal and longest-serving political adviser, who, along with Mr. Cohen, was one of five people originally surrounding the president when he was considering a presidential campaign before 2016.

Now, for the first time, the traffic may be going Mr. Cohen’s way. Mr. Trump’s lawyers and advisers have become resigned to the strong possibility that Mr. Cohen, who has a wife and two children and faces the prospect of devastating legal fees, if not criminal charges, could end up cooperating with federal officials who are investigating him for activity that could relate, at least in part, to work he did for Mr. Trump.

[Mr. Trump on Saturday morning harshly criticized this article in a series of tweets. Read more.]

Last week federal agents raided Mr. Cohen’s office and hotel room and seized business records, emails and other material as part of what Mr. Trump has called a “witch hunt” by his own Justice Department. The trove included documents dating back decades, as well as more recent ones related to a payment in 2016 to a pornographic film actress who has said she had a sexual encounter with Mr. Trump, which Mr. Trump denies.

Although Mr. Trump called Mr. Cohen last Friday, four days after the raid, to “check in,’’ according to people familiar with the call, he and Mr. Cohen have spoken little since Mr. Trump entered the White House. The two men did have dinner together at Mar-a-Lago, Mr. Trump’s private club in Florida, a few weeks ago, but since the raid Mr. Cohen has told associates he feels isolated.

Mr. Trump has long felt he had leverage over Mr. Cohen, but people who have worked for the president said the raid has changed all that.

“Ironically, Michael now holds the leverage over Trump,” said Sam Nunberg, a former aide to Mr. Trump who worked with Mr. Cohen and Mr. Stone. Mr. Nunberg said that Mr. Cohen “should maximize” that leverage.

“The softer side of the president genuinely has an affection for Michael,” Mr. Nunberg said. For instance, Mr. Trump attended the bar and bat mitzvahs of Mr. Cohen’s children. “However, the president has also taken Michael for granted.” Mr. Nunberg added that “whenever anyone complains to me about Trump screwing them over, my reflexive response is that person has nothing to complain about compared to Michael.”

Image

Mr. Trump and Mr. Cohen, far right in New Hampshire in 2011.CreditJim Cole/Associated Press

Mr. Stone recalled Mr. Trump saying of Mr. Cohen, “He owns some of the finest Trump real estate in the country — paid top dollar for it, too.” In Mr. Trump’s worldview, there are few insults more devastating than saying someone overpaid.

For years, Mr. Cohen has described himself as unflinchingly devoted to Mr. Trump, whom he has admired since high school. He has told interviewers that he has never heard Mr. Trump utter an inaccuracy or break a promise. He has tweeted about Mr. Trump nearly 3,000 times.

In a Fox News interview last year, Mr. Cohen declared: “I will do anything to protect Mr. Trump.’’ He told Vanity Fair in September that “I’m the guy who would take a bullet for the president,” adding, “I’d never walk away.”

At a Republican fund-raiser at Mar-a-Lago earlier this year, Mr. Cohen went so far as to approach the first lady, Melania Trump, to try to apologize for the pain he caused her with the payment to Stephanie Clifford, known as Stormy Daniels, the adult film actress who has claimed to have had the sexual encounter with Mr. Trump.

Over the years, Mr. Trump threatened to fire Mr. Cohen over deals that didn’t work out, or snafus with business projects, people who were present for the discussions said. He was aware that Mr. Cohen benefited in other business projects as being seen as affiliated with the Trump Organization, and it irked him.

“He clearly doesn’t think that Michael Cohen is his Roy Cohn,” said Tim O’Brien, a Trump biographer, referring to Mr. Trump’s former mentor and the president’s ideal for a pit bull-like defender. “I think his abusive behavior to Michael is animated by his feeling that Michael is inadequate.”

Prosecutors have argued that Mr. Cohen did little actual legal work for Mr. Trump and instead focused on extensive political, media and real-estate dealings for the president.

Michael D’Antonio, another Trump biographer, recalled Mr. Cohen calling him soon before the book was published.

“He wanted to know if I was going to call Trump a racist and he wanted to know” if it would include an old allegation from Mr. Trump’s wife, Ivana Trump, that he had committed marital rape, Mr. D’Antonio said.

Mr. Cohen also wanted the title of the book, which was originally “Never Enough,” changed, Mr. D’Antonio said. He recalled saying to Mr. Cohen, “When has it ever been enough for Donald?”

“And Cohen started laughing, and he said, ‘I don’t have a problem with the title personally,’” Mr. D’Antonio recalled. Nonetheless, he said, Mr. Cohen said he would call the publisher to get the title changed, and then threatened a lawsuit when he couldn’t.

In 2007, Mr. Cohen was dispatched, along with Ivanka Trump, to scout a golf course development project in Fresno, Calif., that didn’t materialize. The next year, he served as chief operating officer of Affliction Entertainment, a Trump mixed-martial arts venture of boxing, wrestling and karate that featured a Russian Army veteran named Fedor Emelianenko. (“His thing is inflicting death on people,” Mr. Trump said at the time.)

Mr. Cohen has been active in Mr. Trump’s political ventures. When Mr. Trump pondered running for president in 2012, it was Mr. Cohen who went on an early trip to Iowa to meet with Republican operatives and who set up a website called ShouldTrumpRun.org. He even initially sought to pay some of the costs for the site with money raised for his own abortive run for New York State Senate.

Mr. Trump never ran in 2012, but Mr. Cohen raised $500,000 in four hours for the Mitt Romney presidential campaign that year during one of their “national call days” — and had campaign officials credit it as money that his boss had raised, one former Romney official recalled. When Mr. Trump ran for president in 2016, Mr. Cohen was given no official role on the campaign.

He fought with the initial campaign manager, Corey Lewandowski. Paul Manafort, the campaign chairman, later blocked him from coming on board. Mr. Trump never ordered his aides to make a place for Mr. Cohen.

Some of Mr. Cohen’s efforts to help only led to embarrassing rebuffs in front of those in charge. A month before the election, Mr. Cohen approached Mr. Trump outside his Trump Tower office with photographs of Bill Clinton and a mixed-race man alleged — without any evidence — to be the former president’s illegitimate son. Mr. Trump knocked the papers away, angrily telling Mr. Cohen to “get that out of my face,” said one former campaign official who witnessed the incident.

Particularly hurtful to Mr. Cohen was the way Mr. Trump lavished approval on Mr. Lewandowski in a way he never did for Mr. Cohen. When Mr. Cohen told Mr. Trump that he believed that Mr. Lewandowski had been behind a negative story about Mr. Trump’s son-in-law, Jared Kushner, Mr. Trump dismissed the comments as simple jealousy, and didn’t pay attention, according to two people familiar with the incident.

Mr. Cohen raised millions of dollars for Mr. Trump in the campaign, at a time when the candidate was struggling to attract support. Mr. Cohen tried to soften the edges as Mr. Trump faced a torrent of criticism for decades of racially divisive remarks, forming a “diversity coalition” to give Mr. Trump cover composed of African-Americans, Muslims and other groups.

“Nobody else around Donald Trump would have thought to do that for him,” said Darrell Scott, an African-American pastor from Ohio and a friend of Mr. Cohen who helped created the coalition.

A version of this article appears in print on , on Page A1 of the New York edition with the headline: Punching Bag For President Now Has Clout. Order Reprints | Today’s Paper | Subscribe