Baghaei was Mahmoud Ahmadinejad's vice president in charge of executive affairs. He was briefly detained in 2015, and his trial on corruption charges began later that year but he wasn't in custody.
In May, Baghaei applied to run for president but was rejected. He has 20 days to appeal.
The verdict comes against the backdrop of frequent criticism by Ahmadinejad and his allies against the judiciary.
Ahmadinejad on Tuesday called Iran's chief justice, Ayatollah Sadegh Amoli Larijani, "incompetent."
More about: #Iran