A long-running Justice Department investigation of two of Washington’s best-known lobbyists was closed this week, the latest sign of the challenges facing prosecutors attempting to more aggressively pursue possible violations of foreign lobbying rules.

Tony Podesta, a longtime Democratic power broker, and Vin Weber, a Republican former congressman, said they were notified Monday that federal prosecutors in Manhattan had closed the inquiry into work they did that benefited Ukrainian interests.

“It’s been a long two years,” Podesta said. “I’m happy that it’s over and happy that I can go on with the rest of my life without looking at this every day.”

An attorney for Weber, Robert P. Trout, said, “We are obviously pleased by this development,” adding that “at all times Mr. Weber acted in good faith and in keeping with the legal advice his company received from its outside counsel.”

A spokesman for the U.S. attorney’s office in the Southern District of New York, which had been handling the investigation, declined to comment.

Both Podesta and Weber’s consulting firm, Mercury, have said that they cooperated with prosecutors and worked to follow the law.

“We expected this outcome because we did the right thing from the start,” said Michael McKeon, a Mercury partner. “After getting a long, hard look we came out clean because that’s how we run our business. We are especially happy for Vin Weber, who deserves this clean bill of health.”

The decision to drop the investigation came weeks after a federal jury in Washington found former White House counsel Gregory B. Craig not guilty of lying to the Justice Department about his media contacts related to his work for the Ukrainian government.

The Ukrainian lobbying investigations largely grew out of special counsel Robert S. Mueller III’s inquiry and the prosecution of former Trump campaign chairman Paul Manafort, who is now serving a 7½-year prison sentence.

Weber and Podesta were among several lobbyists and lawyers that Manafort helped bring aboard as part of an effort to improve the image of the Ukrainian government between 2012 and 2014, according to Mueller’s report.

Mueller ultimately referred the case involving the two men to federal prosecutors in New York.

Investigators have been seeking to determine in part whether Weber and Podesta had violated the Foreign Agents Registration Act — a law that requires those who seek to influence the United States on behalf of another government to register with the Justice Department.

The Podesta Group and Mercury reported in lobbying disclosures that they had represented the European Center for a Modern Ukraine, a Brussels-based nonprofit organization that sought to help Ukraine improve its image in the West.

Prosecutors alleged in the Manafort prosecution that the lobbying work was being directed by Manafort and Trump campaign official Rick Gates, and that the real client was the government of Ukraine.

As the investigation proceeded, Podesta closed his iconic lobbying firm, the Podesta Group, in the fall of 2017. Weber left Mercury, a firm he had helped lead since 2011, in August.

After Mueller’s probe, foreign lobbying registrations under the act spiked, and the Justice Department sought to enforce the law more aggressively. Earlier this year, a top national security official announced that the department had overhauled the unit that prosecutes such cases and assigned a former Mueller prosecutor, Brandon Van Grack, to lead it.

But successfully bringing prosecutions of unregistered foreign agents has long been challenging. A 2016 Justice Department inspector general report found that the law was rarely enforced, and Justice Department officials and agents generally had different understandings of the act and how to apply it.

Earlier this month, the department failed one of its first big tests to win a conviction of someone investigated as possibly violating the law when jurors acquitted Craig of concealing media contacts in 2012 related to his work for the Ukrainian government.

Craig initially had been charged with making false statements under the Foreign Agents Registration Act, though a judge dismissed that count, citing a lack of clarity in the law, and jurors further acquitted him of a general false-statements charge. That case was ultimately handled by the U.S. attorney’s office in Washington, after the U.S. attorney’s office in the Southern District of New York declined to press the Craig matter. It nonetheless continued to investigate Weber and Podesta.