In the 2005 election he ran for a third term in office, placing first in the first round of elections but ultimately losing to rival Mahmoud Ahmadinejad in the run-off. He and his family faced political isolation for their support of the opposition in 2009. Rafsanjani entered the race for the 2013 presidential election, but he was disqualified by the Guardian Council. With Hassan Rouhani’s election, in which Rafsanjani openly supported him, the Rafsanjani family gradually recovered their political reputation. Rafsanjani died in 2017, following a heart attack, in a hospital in Capital at the age of 82.