WARSAW — The Polish Supreme Court on Tuesday rejected a government request to extradite Roman Polanski, the Oscar-winning filmmaker, to the United States over a decades-old conviction for having sex with a 13-year-old girl.

The decision almost certainly ends the legal battle in Poland over how to deal with Mr. Polanski, although as a practical matter, even a ruling in favor of the government would have had little effect. Mr. Polanski, a dual citizen of France and Poland, lives in France, which does not extradite its citizens.

Judge Michal Laskowski ruled that a lower court’s verdict was not a “flagrant violation of the law,” as the request for an appeal had claimed. “The regional court of Krakow considered and verified all evidence exceptionally carefully,” Judge Laskowski said.

The legal effort reflects a broader push by the conservative Law and Justice government, which since coming to power a year ago has been calling for a return to Roman Catholic values in Poland, to try to reinforce its reputation as a law-and-order party.