WASHINGTON—The Justice Department experienced two major setbacks in its crackdown on agents of foreign governments on Tuesday, dealing a blow to a high-profile enforcement effort that took center stage during special counsel Robert Mueller’s investigation.

A federal judge overturned the criminal conviction of a former business partner to ex-Trump national security adviser Mike Flynn in an opinion released Tuesday evening. Hours earlier, federal prosecutors in Manhattan alerted defense attorneys they had closed an investigation...