Roman Polanski went to Switzerland to receive a lifetime achievement award
A Swiss court has accepted film-maker Roman Polanski's plea to be freed on $4.5m bail from a Swiss jail where he is being held for a US child sex case.
The court said Polanski could stay at his chalet in the Swiss Alps. He would be monitored by an electronic tag.
Polanski, 76, has been wanted in the US since fleeing the country in 1978 after pleading guilty to having unlawful sex a year earlier with a 13-year-old girl.
He was held in Zurich after travelling from France in September.
On Wednesday, the Swiss Federal Criminal Court accepted Polanski's bail plea and his offer to surrender his passport.
1977 - Polanski admits unlawful sex with Samantha Geimer, 13, in Los Angeles
1978 - flees to Britain after US arrest warrant is issued
1978 - immediately moves to France where he holds citizenship
1978 - settles in France, where he is protected by France's limited extradition with US
2008 - Polanski's lawyer demands case be dismissed and hearing moved out of LA court
2009 - Polanski's request to have hearing outside LA is denied
Sept 2009 - Polanski held in Switzerland after travelling from France to collect an award
Oct 2009 - Swiss court rejects his appeal to be released on bail
The court said Polanski would be subjected to "constant electronic surveillance" at his chalet and an electronic tag would be activated if he attempted to leave the premises.
It also said that Polanski - who holds dual French and Polish citizenship - would stay in the prison pending a possible appeal against the ruling.
The Swiss justice ministry has 10 days to appeal against the court's decision.
But Justice Minister Eveline Widmer-Schlumpf said she saw no reason to appeal against the decision.
It is highly unusual for extradition subjects to be granted bail in Switzerland, says the BBC's Imogen Foulkes, adding that Polanski's first application was refused.
But this time the court ruled bail conditions should be enough to prevent him fleeing back to France, our correspondent says.
The ruling is not thought to affect the Swiss government's ongoing assessment of whether it should extradite Polanski to the US.
Polanski has not set foot in the US since fleeing the country in 1978, and has settled in France.
Speaking after detention in September, US prosecutors disputed claims that his arrest came out of the blue, saying he had been on an Interpol "wanted list" for years.