Hossein Ferydoun was freed on Monday night after reportedly paying millions of dollars of bail.
Mr Ferydoun is believed to have been taken in for questioning on Saturday in connection with a corruption probe.
His detention was seen by some commentators as part of a feud between the president and the judiciary.
Mr Rouhani, a relative moderate, openly attacked the conservative-dominated judiciary and security services during his re-election campaign earlier this year. He criticised arrests made on loose grounds and called for the release of political prisoners.
It is unclear exactly why Mr Ferydoun was summoned for questioning. Judiciary spokesman, Gholamhossein Mohseni-Ejeie said he was the subject of "multiple investigations".
Although he did not occupy an official position, Mr Ferydoun was a close aide to Mr Rouhani during his first term in office, participating in negotiations with world powers over Iran's nuclear programme.
Mr Ferydoun has been linked to last year's so-called "payslip scandal", where some public sector officials were found to have been paid exorbitant salaries.
He has not been charged with any offence and has denied any wrongdoing.
His detention at the weekend was ordered after he failed to pay bail, initially reported to be as much as 500bn rials ($15.3m; £11.5m).
Mr Ferydoun was transferred to hospital on Monday after falling ill during a court appearance, according to the Tasnim news agency.
President Rouhani has not yet commented on his brother's case.