KRAKOW, Poland — A judge in Poland on Friday turned down a request by the United States for the extradition of the filmmaker Roman Polanski, who is wanted over a 1977 conviction for having sex with a 13-year-old girl.
At a hearing in Krakow, Judge Dariusz Mazur ruled that turning over Mr. Polanski would be an “obviously unlawful” deprivation of liberty and that California would be unlikely to provide humane living conditions for the filmmaker, who is 82.
“I am very happy that the case is ending,” Mr. Polanski said at a news conference in Krakow after the ruling, the latest development in a 38-year trans-Atlantic legal controversy. “This has been a tremendous burden on me and my family.”
Mr. Polanski, a citizen of France and Poland, has been working on a film in Poland about Alfred Dreyfus, a French Army captain who was wrongly convicted of spying for Germany in 1894.
Over the years, prosecutors and judges in Los Angeles have said that Mr. Polanski must return to the United States to face sentencing. His lawyers have asserted that improprieties by the trial judge and others violated his legal rights.
Judge Mazur sided with Mr. Polanski’s lawyers. “I’m terrified by the statements of some of my colleagues in the U.S.,” he said, citing a report last year that a Los Angeles judge had planned to have Mr. Polanski “cool his heels in jail” if he returned to the United States by delaying a ruling on a proposed deal under which the judge would limit his sentence to 42 days served by the filmmaker in 1977-78. (The deal did not materialize.)
“If I were to behave like them, I’d lose the respect of all my subordinates here,” Judge Mazur said. “I do not find any logical, rational explanation as to why the U.S. is pursuing the extradition.”
Mr. Polanski did not attend the hearing but said afterward, “I am happy that I trusted the Polish justice system.” He praised the judge as “incredibly well-informed,” adding, “Frankly, I was moved.”
Judge Mazur’s ruling is not necessarily the final step in the Polish case; prosecutors could appeal. “We will wait until we get the full decision in writing before deciding whether to appeal,” the regional prosecutor, Danuta Bieniarz, said after the ruling. (Complicating the matter, an influential politician in the right-wing party that drew the most votes in parliamentary elections on Sunday, Mariusz Blaszczak, has expressed sympathy for the American position.)
A lawyer for Mr. Polanski, Jan Olszewski, had argued passionately against the extradition, which the United States formally requested from the Polish government in January. “The victim in this case did not want jail time for Polanski,” Mr. Olszewski said. “She forgave him. This is rare in this kind of case.”
He added: “This is not a matter of justice. This is not about the victim. She said that the whole proceeding has harmed her more than what Mr. Polanski did to her.”
Mr. Olszweski and another defense lawyer, Jerzy Stachowicz, repeatedly cited the 2008 documentary “Roman Polanski: Wanted and Desired,” which suggested prosecutorial overreach and judicial misconduct by officials in the United States. They argued that extraditing Mr. Polanski would violate the European Convention on Human Rights and his right to a fair trial.
In contrast, Ms. Bieniarz, the regional prosecutor, kept her argument brief. “In our opinion, there are no legal grounds to stop the extradition,” she told Judge Mazur. “The case has not expired under American law, and we do not think that the extradition is unlawful, on the basis of Polish law. There is no proof that Polanski will be treated inhumanely in the United States.”
Shiara Dávila-Morales, a spokeswoman for the Los Angeles County District Attorney’s office, said in a statement, “Our position on this matter remains the same.” A spokeswoman from the Los Angeles County Superior Court declined to comment.
The legal decision in Poland follows Switzerland’s refusal in 2010 to extradite Mr. Polanski. He had been arrested at the Zurich airport and held for about 10 months during a series of hearings similar to the ones in Poland.
In Switzerland, the authorities said that they had not been given enough information about the case to justify sending Mr. Polanski to the United States for sentencing. They pointed in particular to a failure by officials in Los Angeles to forward sealed testimony by Roger Gunson, a now-retired lawyer who originally prosecuted the case.
Mr. Gunson gave provisional testimony in 2009, when he was gravely ill, about a plan by the 1970s trial judge, Laurence J. Rittenband, to limit Mr. Polanski’s sentence to a 90-day psychiatric evaluation, a portion of which Mr. Polanski served in Chino State Prison. Mr. Gunson’s account was not provided to the Polish court.
Mr. Gunson is still alive, and the testimony has not been unsealed. Judge Rittenband died in 1993.
Mr. Polanski was first arrested in 1977 on charges that included the rape of the 13-year-old girl at the home of the actor Jack Nicholson. In 1978, he fled the United States on the eve of sentencing under an agreement by which he was to plead guilty to a count of statutory rape.
Mr. Polanski left the country after learning that Judge Rittenband had decided to revise his plan to limit his sentence.
The victim in the case for which Mr. Polanski was convicted, Samantha Geimer, who revisited the legal proceedings in a 2013 memoir, wrote on her Facebook page on Friday: “If they were smart, they’d stop trying to bring him back. If they ever do, the truth about the corruption in the D.A.’s office and court will finally be known.”
In December, Judge James R. Brandlin of the Los Angeles County Superior Court dismissed a motion in which Alan M. Dershowitz, who then represented Mr. Polanski, argued that prosecutors had provided false information to the Swiss authorities. The motion also cited internal court emails that Mr. Dershowitz contended were evidence that a Superior Court judge in 2009 unethically prejudged issues related to the case.
In 2009, a California appeals court panel suggested that Mr. Polanski could be sentenced in absentia, opening the way to possible resolution of the long standoff. But that suggestion was rejected by the Superior Court.
Mr. Polanski is now represented in the United States by Harland W. Braun, a defense lawyer whose celebrity clients have included the actors Robert Blake, Gary Busey and Roseanne Barr. After the retirement of Mr. Polanski’s longtime lawyer, Douglas Dalton, Mr. Braun was recruited for the job by the Hollywood filmmaker and power broker Brett Ratner.
In an email, Mr. Braun noted that the Polish judge had cited emails that “had been hidden for many years” in announcing his decision. Mr. Braun urged that the case be removed from the Los Angeles court system and that Mr. Polanski “be sentenced in absentia as suggested by an appellate court many years ago.”
Since 2012, Mr. Polanski has talked of directing the film about Captain Dreyfus, whose 1894 trial stirred accusations of anti-Semitism and polarized France. Mr. Polanski has said he views the film, of which Mr. Ratner is a producer and an investor, as a way to teach lessons about official misbehavior.
Because of an editing error, an earlier version of a picture caption with this article misidentified the lawyer photographed with the filmmaker Roman Polanski. He is Jerzy Stachowicz, not Jan Olszewski.
Correction: October 30, 2015
An earlier version of the headline with this article used an erroneous verb to describe the request that was rejected. The United States wanted Roman Polanski extradited, not expedited.