Those comments were directed at one of Mr. Trump’s aides who was in the room at the time, Mr. Parnas has previously said.

Ms. Yovanovitch remained in her job for another year after Mr. Trump’s remarks until she was recalled on the White House’s orders, according to testimony in the impeachment inquiry. It is not clear whether the president changed his mind, forgot about his order or was talked out of dismissing her.

Asked about the recording by Fox News, Mr. Trump said he was “not a big fan” of Ms. Yovanovitch. “I want ambassadors that are chosen by me,” he said. “I have a right to hire and fire ambassadors, and that’s a very important thing.”

The campaign to remove Ms. Yovanovitch is among the central elements of the Democratic case that Mr. Trump abused his power in an effort to pressure Ukraine’s government into announcing investigations into purported meddling in the 2016 election and into former Vice President Joseph R. Biden Jr. and his diplomacy in Ukraine.

Mr. Parnas had previously recounted how he and another associate of Mr. Giuliani’s, Igor Fruman, had met with Mr. Trump during a dinner for a small group of donors in a private suite at the Trump International Hotel in Washington in late April 2018. At that dinner, Mr. Parnas relayed a rumor that Ms. Yovanovitch, then the American ambassador in Kyiv, was bad-mouthing the president — an unsubstantiated claim that Ms. Yovanovitch has denied.

Republicans have sought to challenge Mr. Parnas’s credibility by noting that he is under indictment. But the recording seemed to buttress his claims that he had discussions with Mr. Trump about ousting Ms. Yovanovitch, who Mr. Parnas and Mr. Giuliani later came to believe was blocking their efforts to press the Ukrainians to commit to the investigations.

Mr. Parnas and Mr. Fruman had obtained direct access to the president by donating to Republican committees, and the recording suggests he spoke in front of them in a remarkably unfiltered and undiplomatic way, given their relative obscurity.