Dominique Strauss-Kahn has been granted bail by a judge in a New York court, after being formally charged with trying to rape a hotel maid.
Mr Strauss-Kahn had earlier resigned as the International Monetary Fund's boss.
His lawyers said he was honourable and would not try to abscond. Prosecutors said he had "incentive to flee".
Supreme Court Justice Michael Obus imposed $1m cash bail and said there must be 24-hour home detention, with an armed guard and electronic monitoring.
The judge said one armed guard must be deployed at all times, at Mr Strauss-Kahn's expense, and the defendant must surrender all travel documents. In addition to the $1m (£618,000) cash bail, a $5m insurance bond would also apply.
Mr Strauss-Kahn will spend a fourth night at the notorious Rikers Island prison on Thursday before the bail papers are signed.
He will appear in court again on 6 June, when he will formally enter a plea. He has denied all the accusations against him.
'Life of ease'
Mr Strauss-Kahn's wife, Anne Sinclair, was in court for Thursday's hearing.
The Frenchman - who was not wearing handcuffs or shackles, but was flanked by four police officers - smiled at her as he entered the Manhattan courtroom.
Mr Strauss-Kahn had been denied bail at an earlier hearing on Monday.
But defence lawyers said the prosecution's bail position was unfair and not consistent with the law.
The prosecution said Mr Strauss-Kahn, 62, had left the alleged crime scene with "unusual haste" and that any bail arrangement would be insufficient.
The judge asked for details of Mr Strauss-Kahn's financial situation.
The defence said he had a net worth of roughly $2m and offered $1m bail.
Prosecutor John McConnell said this was "unreasonable", adding: "We are in possession right now of only one passport. We simply don't know what other documents he has access to or could get."
He said Mr Strauss-Kahn had the means to live "a life of ease and comfort" in parts of the world "beyond this country's jurisdiction".
But Mr Strauss-Kahn's lawyer, William Taylor, said: "The prospect of Mr Strauss-Kahn teleporting himself to France and living there as an accused sex offender, fugitive, is ludicrous."
After the ruling, Mr Taylor said: "We want to express our pleasure that the judge has made this decision. It's great relief to the family to be able to have him with them."
Mr Strauss-Kahn has now been formally charged following a grand jury hearing, attended on Wednesday by his accuser, a 32-year-old originally from Guinea in west Africa.
The charges set out by the New York district attorney's office included four felony counts - two of criminal sexual acts, one of attempted rape and one of sexual abuse - plus three misdemeanour offences, including unlawful imprisonment.
Manhattan district attorney Cyrus Vance said Mr Strauss-Kahn had been indicted on all the charges presented to the grand jury.
The incident allegedly took place at New York's Sofitel hotel on 14 May.
Mr Strauss-Kahn earlier announced his resignation from the IMF.
In a statement posted on the IMF website late on Wednesday, he said he had resigned with "infinite sadness" but wanted to "devote all my strength, all my time, and all my energy to proving my innocence".
His resignation has sparked debate about his successor.
Leading voices in Europe say another European should head the fund.
A number of figures have voiced support for French Finance Minister Christine Lagarde.