Khatami, who during his 1997-2005 presidency oversaw a rapprochement with the West, has been barred from speaking openly since mass protests against the disputed reelection of his hardline successor Mahmoud Ahmadinejad in 2009.
The hardliner's replacement by Rouhani in 2013 has seen a nuclear deal between Iran and world powers that led to the lifting of most international economic sanctions but is threatened by a tougher stance from the new US administration of Donald Trump.
"The interest of the people and the country is in the continuation of Rouhani's government," Khatami added.
Rouhani faces a tough campaign against two conservative challengers amid disappointment that the 2015 nuclear deal has not brought bigger economic dividends.
More From This Section
Both Tehran mayor Mohammad Bagher Ghalibaf and cleric- turned-judge Ebrahim Raisi have played on the concerns of the poor.
Khatami, 73, was an important figure in Rouhani's first- term election victory, convincing reformist candidate Mohammad Reza Aref to stand aside in his favour.
In parliamentary elections last year, Khatami skirted the ban by publishing a video on YouTube and mobile messaging apps to call on voters in the capital to choose a pro-Rouhani list.
All 30 candidates of the "List of Hope" won, defeating many leading conservatives.