A Polish court has rejected a request to extradite film director Roman Polanski to the US for having sex with a girl of 13 there in the 1970s.
Judge Dariusz Mazur said the request was "inadmissible". However prosecutors can still appeal against the ruling.
The 82-year-old Oscar-winning director was not present for Friday's court session in Krakow.
Polanski, who admitted unlawful sex with a minor - statutory rape - fled the US ahead of sentencing in 1978.
After the ruling, Polanski said he was "very happy" the case was coming to a close.
"I feel relieved but tired... it cost me a lot of energy, a lot of time," he told reporters in Krakow
Polanski has French and Polish citizenship. He lives in France - which does not extradite its own citizens - but has been working in Poland on a film project.
Swiss authorities turned down a US extradition warrant in 2010, after placing Polanski under house arrest for nine months.
The film director's Polish lawyers had argued against his extradition, citing claimed legal flaws in the US process and the 42 days Polanski served in prison at the time, according to the Associated Press news agency.
Polanski grew up in Poland and is regarded as one of the country's greatest living artists.
He survived World War Two in the Krakow ghetto but his mother died at Auschwitz.
Polish voters elected a conservative government at the weekend - and officials from the Law and Justice party had said Polanski should be sent to America to face justice.
If a Polish court were to rule in favour of extradition, the final decision would rest with the justice secretary.
1977: Polanski is arrested and charged with a string of offences relating to sex with a 13-year-old girl. These charges are dropped after he pleads guilty to unlawful sexual intercourse with a minor - statutory rape - in a plea bargain.
1978: Fearing that he may face a lengthy jail term, Polanski flees to the UK and then to France. A citizen of France, he is protected by the country's limited extradition with the US.
2009: The US rejects Polanski's request for the case to be dismissed. Visiting Switzerland later that year, he is jailed, then placed under house arrest following a US extradition request.
2010: Swiss authorities decide against extraditing Polanski and free him.
2014: Polanski is questioned by prosecutors in Poland, acting on a US request. He agrees to comply with the Polish justice system as it examines the matter.