PARIS — Iran has released the French academic Roland Marchal, an official in the French president’s office said on Saturday, as part of a prisoner swap agreement with France.

Mr. Marchal, who had been imprisoned in Iran since June on security charges, was due to arrive in France around midday Saturday, the official said.

Iran and France had agreed to swap Mr. Marchal and Jalal Ruhollahnejad, an Iranian engineer detained by the French authorities over accusations that he violated U.S. sanctions against Tehran, Iranian state media reported on Friday. France had already released Mr. Ruhollahnejad, the state broadcaster IRIB reported.

The broadcaster said that Mr. Marchal had been “sentenced to five years’ imprisonment for acting against national security,” adding that his sentence had been reduced and he was handed over to the French embassy in Tehran.