The decision by Mohammad Reza Aref is seen as a major boost for Hasan Rowhani, who now faces off against five conservative candidates.
Aref's website Draref.ir said he made the decision at the urging of reformist ex-president Mohammad Khatami. State TV and media also reported his withdrawal.
Aref said he received a message from Khatami telling him that his continued candidacy "is not in the interest" of Iran's reformers. He said his campaign could be a "base and great social capital" for the reform movement.
Aref has been a close ally of Khatami's since his presidency in 1997-2005. Rowhani meanwhile has close ties with both Khatami and another influential former president, Akbar Hashemi Rafsanjani, who was barred in May from running in the election by a clerically run constitutional watchdog.
On Monday, a hardline candidate withdrew to avoiding splitting the vote with other conservative candidates.
Under the Iranian system, if no candidate gets a majority in the first round, then the top two have a run-off.
The election will choose a successor for outgoing President Mahmoud Ahmadineajd who under the law cannot run for another term.