A lawyer for the men, John M. Dowd, who was not at the hearing, declined to comment. His clients were ordered to appear in court on Thursday in New York, where the charges were filed.

The work the two men did in Ukraine for Mr. Giuliani seems to have been a mixture of business and politics. Mr. Parnas advised Mr. Giuliani on energy deals in the region and pursued his own in Ukraine even as he portrayed himself as a representative of Mr. Giuliani on the Trump-related matters.

The indictment said Mr. Parnas acted “at least in part, at the request of one or more Ukrainian government officials.” None were named, but Ms. Yovanovitch’s main critic in the Ukrainian government was Yuriy Lutsenko, then the nation’s prosecutor general who himself has a history of wielding the law as a weapon in his personal political battles.

Both Mr. Fruman and Mr. Parnas appear to have at least glancing contacts with Mr. Trump. Mr. Trump invited Mr. Fruman to a fund-raiser last year at the president’s Mar-a-Lago estate in Florida, he said in an interview with Forum Daily, a publication that bills itself as the “voice of Russian-speaking America.” The article featured a photograph of the two men, with the president giving a thumbs-up sign.

Mr. Parnas posted a photo on Twitter this spring of himself with the president and wished Mr. Trump a happy birthday. “I am honored to call you Mr. President!!!” he wrote. “And my friend!!”

The president sought to distance himself from the men as he left the White House on Thursday en route to a political rally in Minnesota.

“I don’t know those gentlemen,” Mr. Trump said. “Now it’s possible I have a picture with them because I have a picture with everybody. I don’t know about them. I don’t know what they do. I don’t know, maybe they were clients of Rudy. You’d have to ask Rudy.”