Novartis said that after it determined that Mr. Cohen could not provide the services he offered, the company wanted to terminate his contract. But the drug giant learned it could do so only for cause, so it allowed the contract to expire.

Joe Jimenez, the chief executive at Novartis at the time the deal was signed with Mr. Cohen, left the company in January. His replacement, Vasant Narasimhan, took over the next month, and the company has said he had no role in the arrangement. Mr. Narasimhan dined with Mr. Trump along with other European business leaders at this year’s World Economic Forum, but Novartis said his presence at the dinner had nothing to do with the payments to Mr. Cohen.

Mr. Jimenez did not respond to requests for comment.

Like Novartis, AT&T was also scrambling to adjust to the new White House at the start of Mr. Trump’s term. Inside the company’s Washington office, which had close ties to traditional Republican circles, staff members were concerned that they lacked connections to the Trump administration. In addition, one of its top executives in Washington had been a vocal opponent of Mr. Trump during the campaign.

Mr. Cohen provided advice on how AT&T should approach the administration about its $85.4 billion merger and regulatory issues before the Federal Communications Commission, according to the person familiar with the agreement.

AT&T said Mr. Cohen was one of several consultants it retained at the start of Mr. Trump’s term to help it better understand the president’s thinking. “Companies often hire consultants for these purposes, especially at the beginning of a new presidential administration, and we have done so in previous administrations, as well,” the company said Wednesday in a note to employees.

Companies do commonly hire consultants with ties to politicians for strategic advice. In the Trump administration, several former campaign and transition officials set up consulting firms — some that do not fall under the lobbying disclosure laws — to advise clients on the president’s possible thinking on mergers, regulations and legislation related to taxes and trade.