President Trump’s financial gatekeeper was granted immunity by federal authorities in New York and testified before a grand jury, the third longtime confidant of Mr. Trump known to have provided information in an illegal hush-money investigation that has implicated the president.

Allen Weisselberg, who has served for decades as chief financial officer and executive vice president of the Trump Organization, testified several weeks ago in the criminal investigation by federal prosecutors in Manhattan into Michael Cohen, Mr. Trump’s former lawyer, people familiar with the matter said.

Earlier this week, Mr. Cohen pleaded guilty in Manhattan federal court to eight criminal charges, including facilitating illegal campaign contributions during the 2016 presidential campaign to pay hush money to two women. He said Mr. Trump directed him to make the payments.

Mr. Weisselberg was one of the executives who helped reimburse Mr. Cohen through the Trump Organization and the president’s personal trust for a $130,000 payment Mr. Cohen made before the 2016 election to Stephanie Clifford, a former adult-film actress known as Stormy Daniels, for staying silent over her allegation of a past sexual encounter with Mr. Trump, which he has denied.

David Pecker, CEO of the National Enquirer’s publisher and a longtime ally who helped protect Mr. Trump’s public image for years, also was granted immunity and told federal prosecutors that Mr. Trump had knowledge of Mr. Cohen’s payments to women, The Wall Street Journal reported earlier this week.