(CNN) -- A retired prosecutor whose comments in a 2008 HBO documentary threatened to derail a 31-year-old sex case against film director Roman Polanski now says he lied.

David Wells, a former prosecutor, now says he lied about his role in the Roman Polanski case.

David Wells told CNN's Wolf Blitzer on Thursday that he "buttered up" his role in the Polanski case for the documentary crew. He said he lied about trying to goad a judge to sentence Polanski to prison in 1978 for having sex with a 13-year-old girl.

Wells' comments in "Roman Polanski: Wanted and Desired" raised questions of judicial misconduct and spawned Polanski's most recent effort to get the case dismissed. But the legal challenge stalled when Polanski refused to return to the United States, where he faced certain arrest.

"I made these imprudent comments, just to liven it up a little," Wells said. "In retrospect, it was a bad thing to do, and I never knew this thing was going to be shown in the United States." Watch Wells' rueful admission »

Wells now says he never spoke with the judge about the Polanski case, as he had claimed in the documentary. "I never discussed this case with [the judge] at any time," Wells told Blitzer.

Asked why he should be believed now, Wells said, "I'm destroying my character in public and everybody in the world knows about it. ... I don't like admitting this."

He agreed to take a polygraph test to set the record straight.

Polanski was arrested last weekend in Switzerland on a 1978 fugitive warrant and will fight extradition, his lawyers said. They had no immediate comment on Wells' recantation.

"I am astonished that he has now changed his story," Marina Zenovich, the documentary's director, said in an e-mailed statement. "It is a sad day for documentary filmmakers when something like this happens."

She said Wells signed a release form, never raised any doubts or concerns, and vouched for the documentary when he spoke to The New York Times in July 2008.

Wells also acknowledged that he lied to The New York Times. "I figured Polanski never was going to come back," he said. "I didn't want to put myself out as a liar."

Polanski's arrest in Switzerland made Wells' public exposure inevitable, he said. "I'm going to tell it the way it is and if I take a beating over it, I deserve it," he said.

Blitzer challenged Wells to a polygraph test, and he agreed to take one if his former employers at the Los Angeles County, California, District Attorney's office allow it. "I'm not going to do anything more to hamper the District Attorney's case," he said.

District Attorney's spokeswoman Sandi Gibbons said the office had no position on the polygraph challenge. "Mr. Wells is retired," she said. "We have no control over him."

Wells was a bit player in a high profile case that has haunted the courts of Los Angeles for three decades. He was a calendar prosecutor, handling routine matters in the courtroom of Superior Court Judge Laurence Rittenband, who oversaw the Polanski case.

Rittenband, who died in 1993, had a fascination with celebrity cases, and was so publicity conscious that he directed his courtroom staff to keep a scrapbook of news clippings, according to court records.

Polanski was charged with six felonies, including sodomy and rape, but pleaded guilty to a single count of having unlawful sexual intercourse with a minor under a plea bargain. The director, his lawyer and the prosecutor handling the case believed they'd reached a deal that would spare the young victim a public trial and Polanski jail time, according to court records.

Polanski fled the United States before sentencing. He was spooked when Rittenband indicated he would not honor the deal and instead intended to send the famed director to prison. Watch how the plea bargain went south »

The charges stemmed from Polanski's March 1977 encounter with the 13-year-old girl during a photo shoot at actor Jack Nicholson's house on Mulholland Drive. Polanski told the girl's mother he was on assignment for French Vogue, according to court records.

Wells said he was critical about the manner in which the case was handled. He believed Polanski should go to prison. He told the documentary makers that he suggested to Rittenband that Polanski be sent for 90 days of "diagnostic testing" at a state prison facility in Chino, California, to determine whether he was a sex offender.

He admitted to CNN that he was lying about suggesting the 90-day evaluation, adding that Rittenband routinely sent defendants for evaluation.The evaluation was completed in 42 days, and Polanski was freed early after it determined he was not a sex offender. Watch CNN's Jeff Toobin call it a sideshow »

Polanski was given permission to travel to Europe to complete a film before he was formally sentenced. It was understood by everyone that Polanski would receive credit for time served and probation, according to filings in his legal challenge.

While Polanski was in Europe, Wells said in the documentary, a photograph appeared of the director smoking a cigar, sipping a beer and accompanied by two young women.

A script from the documentary in the court file lays out what Wells said happened next:

"And so I took the picture into Judge Rittenband. I said, 'Judge,' I said, 'look here, he's flipping you off,' " he said. "I took it to Rittenband because I figured it was something he ought to see. And what I told him was, I said, 'You know, judge, you've made so many mistakes, I think, in this case. Look. He's giving you the finger. He's flipping you off. And here's the way he's doing it.' And I said, 'Haven't you had enough of this?' And then, of course, he exploded and what happened, happened."

Wells now says he lied about that, too. He said a newspaper reporter handed him the photo, which he passed on to the judge's court staff.

"I could call it building a bigger story, putting my part in the case bigger than it actually was," he said. "But when you peel away all the feathers, it's just a lie. I shouldn't have done it. I wish I didn't."

All About Roman Polanski • Criminal Sentencing and Punishment • Sexual Offenses