Through a secretive shell company, Michael D. Cohen, President Trump’s personal lawyer, was paid by major corporations for help navigating Washington in the Trump era.

After paying off a pornographic film actress and doing other tasks to help his boss win the presidency, Michael D. Cohen was surprised to find that the doors to the White House were mostly closed to him.

Mr. Cohen did not land a hoped-for job in President Trump’s administration — he imagined himself as chief of staff — and in January last year he left the Trump Organization, where he had long served as the in-house fixer without a clear portfolio. But he managed to turn what looked like an exile into a lucrative opportunity.

Armed with the self-appointed title of “personal attorney” to the president, Mr. Cohen, who had served as a personal-injury lawyer and owned a taxi business, became seen as the man who could help others gain access to the seat of power that had been denied to him. Major corporations including AT&T, Novartis and the law firm Squire Patton Boggs collectively paid him over $2 million for advice about navigating the suddenly foreign terrain of Mr. Trump’s Washington.

Most of the arrangements remained a secret until Tuesday, when details first appeared in an account released by Michael Avenatti, the lawyer for Stephanie Clifford, the actress who was paid $130,000 to keep quiet about her alleged affair with Mr. Trump and is now suing to be released from the agreement. The New York Times confirmed many of Mr. Avenatti’s disclosures through a review of financial records.

On Wednesday, additional details emerged. Novartis, the Swiss drug maker, said it had paid Mr. Cohen $1.2 million after he approached the company early last year promising insights into Mr. Trump’s views on health care. AT&T, which has been pursuing a major corporate merger, said it had paid him $600,000 for advice on regulatory matters.

Details of the transactions were released by Michael Avenatti, the lawyer for the pornographic film actress known as Stormy Daniels.

Both companies also disclosed that they had been contacted last November by investigators for the special counsel, Robert S. Mueller III, who is examining Russian interference in the 2016 election. Mr. Mueller’s team also questioned a Russian oligarch linked to another company, Columbus Nova, a New York-based investment firm, that had paid Mr. Cohen about $500,000 for consulting services last year, according to the financial records.

The payments were among transactions totaling $4.4 million that between October 2016 and January this year flowed through Essential Consultants L.L.C., the same shell company Mr. Cohen used to pay Ms. Clifford, better known as Stormy Daniels. Mr. Cohen faces an investigation into his finances by the Federal Bureau of Investigation, which raided his home and offices last month.

It is not clear what Mr. Cohen delivered for clients. One cut short his contract, while another paid him even after concluding that he could not provide the services he had promised.

Mr. Cohen’s dealings were the focus of intense questioning at a White House briefing on Wednesday, when Sarah Huckabee Sanders, the press secretary, was asked whether the lawyer’s business transactions embarrassed Mr. Trump and were contrary to his pledge to “drain the swamp” of Washington influence peddlers. She fired back: “I think that would be up to those individuals who make the decision to hire someone, just the same way that the companies that you work for make the decision to determine whether or not they think that you’re qualified to serve in a position.”

Quaking on K Street

Some of the contracts with Mr. Cohen were executed at a time when large companies and lobbying firms were scrambling to adjust to life under Mr. Trump. There is always some disruption at the beginning of a new administration as lobbyists with ties to an incoming president seek to profit and firms more associated with the opposition party recalibrate. But Mr. Trump’s election shook K Street, home to many of the capital’s lobbying firms, like an earthquake.

He had pledged during his campaign to stamp out special-interest influence, and came into office with few ties to established Washington lobbying and consulting firms.

“This guy came to office with virtually no K Street constituency, which is virtually unheard-of in the modern era, and so everybody was in a rush to hire people with connections to him,” said Ivan Adler, a partner at the…