He was flown out of Tora prison in Cairo by helicopter, but is now expected to be put under house arrest.
Mr Mubarak, 85, still faces charges of corruption and complicity in the killing of demonstrators during the protests that toppled him in 2011.
His release is seen by many as a sign that the military is rolling back the changes that flowed from the uprising.
On Thursday, a medical helicopter arrived at Tora, as dozens of Mubarak supporters - some waving flags - gathered outside the prison.
Egypt's TV channel then showed the helicopter transferring Mr Mubarak to a military hospital in the capital. The ex-leader was seen being transferred from the aircraft into an ambulance outside the hospital, amid heavy security.
This comes after a court ruled on Wednesday that the former leader must be released in a corruption case.
The ruling came during the hearing on charges that the former president had accepted gifts from state-run publisher al-Ahram. The value of the gifts has since been repaid.
The court said its decision was final and no appeal would be allowed.
Prosecutors have previously brought new charges when courts have ordered Mr Mubarak's release - a move intended to keep the ailing ex-leader in detention.
But shortly after the court ruling, the office of Prime Minister Hazem el-Beblawi said Mr Mubarak would be placed under house arrest after his release.
"In the context of the emergency law, the deputy military commander issued an order that Hosni Mubarak should be put under house arrest," the office said in a statement.
Egypt is under a state of emergency amid the bloodshed which has accompanied the interim government's crackdown on Islamists opposed to the army's ousting of Islamist President Mohammed Morsi on 3 July.
Hundreds of members of the Muslim Brotherhood - the movement from which Mr Morsi comes - have been detained, including its most senior leader Mohammed Badie, who was wanted over alleged incitement to violence and murder.
Mr Mubarak was sentenced to life in jail last year for complicity in the killing of demonstrators, but a retrial was later ordered after his appeal was upheld.
That retrial opened in May but Mr Mubarak has now served the maximum amount of pre-trial detention permitted in the case.
Meanwhile, European Union foreign ministers on Wednesday agreed to stop export licences on military equipment to Egypt and to reassess security co-operation in response to the clampdown.
Arms are provided by individual countries rather than the EU as a whole, mostly by Germany, France and Spain. The UK has already suspended some of its military help.
But the 28-member block's humanitarian aid to Egypt remains unaffected, despite calls from some EU politicians to cut the assistance after more than 900 people were killed in clashes last week.
The violence erupted as security forces cleared two sit-ins in Cairo by people demanding the reinstatement of Mr Morsi.