DETROIT — An interim nuclear agreement between world powers and Iran presents “the perfect time” to press for the release of an ex-Marine being held on spying charges, a former defense secretary and three retired high-ranking generals wrote to President Barack Obama.

The letter, dated Monday and signed by one-time Secretary of Defense William Cohen and retired Gens. Peter Pace, James Jones and Joseph Ralston, calls on the White House to take “immediate action to facilitate the release” of Amir Hekmati, of Michigan, who has spent more than two years in prison in Iran.

Hekmati’s family in the Flint area says he traveled to Iran to visit his grandmothers when he was arrested in 2011. Tehran accused him of being a CIA spy, then tried, convicted and sentenced him to death. Iran’s Supreme Court ordered a retrial in 2012, but he remains imprisoned.

The letter from Cohen and the former military brass comes as a six-month temporary agreement goes into effect this week that partially halts Iran’s nuclear progress. Iran and world powers now will try to forge a permanent deal.

“As Iran and the United States attempt a formal accord in the next six months, now is the perfect time for the release of Mr. Hekmati,” the letter’s authors wrote. “Freeing him is indeed in both nations’ best interests.”

Those who have been following the case of Hekmati have expressed optimism about the moderate tone of President Hassan Rouhani.

The Iranian leader appeared Thursday at the World Economic Forum in Davos, Switzerland, delivering a speech aimed at persuading world leaders of Tehran’s willingness to do business in the global economy.

U.S. Rep. Dan Kildee, a Flint Democrat who represents Hekmati and his family in Congress, said Iran has the opportunity to “show it is serious about re-engaging the global community by releasing Amir.

“He has been unjustly held for over two years, and releasing him now to be reunited with his family in Michigan would be a tangible demonstration to the U.S. and the world that it seeks to rejoin the global community,” Kildee said in a statement.

The Obama administration in November asked for Iran to free Hekmati and two other Americans believed held there.

Hekmati, who was born in Arizona, carries U.S. and Iranian passports.

Monday’s letter, which first was reported by The New York Times, also cites the health of Hekmati’s father as a key reason to bring him home.

“His release would reunite Amir with his dying father, who desperately wants to embrace his son once more,” Cohen, Pace, Jones and Ralston wrote.

Ali Hekmati, a professor at Mott Community College in Flint, has been diagnosed with brain cancer.

“We are humbled but not surprised that such prominent and important Americans are fighting for Amir’s release from Evin prison,” the Hekmati family said in a written release. “Amir served his country admirably, did nothing wrong and has been torn from his family for 877 days.”