Actor/comedian Fred Willard was arrested Wednesday night (Jul 18) on suspicion of committing a lewd act after police say they caught him masturbating inside an adult movie theater in Hollywood.

Law enforcement sources say that a group of undercover vice officers from the LAPD went into Hollywood’s Tiki Theater, where they found the 78-year-old improv actor watching one of the featured movies with his penis exposed, and in his hand.

Willard — famous for his roles in “Best in Show,” “A Mighty Wind,” “For Your Consideration” and “Anchorman” — was reportedly arrested and booked for lewd conduct … but he didn’t spend too much time behind bars, because he was released within a few short hours.

Law enforcement sources tell TMZ … the LAPD vice officers were not conducting a raid … but rather a “random walk-through” of the premises.

We’re told … when theaters like this get their license, they have to allow cops in whenever they want … to inspect.

In fact, the theater has a sign posted in the front which warns customers that the theater is “viewed by LAPD.”

And while the theater’s posted sign also warns, “No Alcohol, No Weapons, No smoking inside” and “No Pets Allowed” … there’s no mention of waxing the dolphin.

When asked about his lewd conduct arrest the next day, Willard told TMZ cameras it was a “big misunderstanding.”

Fred, with his wife by his side, said he and the cops have “a difference of opinion.” He also says “a strange situation” led him to the theater, but says, “It’s all being straightened out.”

Furthermore, TMZ reports that even if he did masturbate in an adult movie theater, Willard may not have broken any lewd conduct laws due to a legal loophole.

Here’s the long and short of it — In California, it’s not automatically illegal to masturbate in a public place like a movie theater … it’s ONLY illegal if the act occurs within eye-shot of people who “might be offended.” That’s the law, folks.

So how does Willard beat the rap? Allow us to make the argument.

Willard’s alleged act occurred in a XXX theater, notorious for showing hardcore porno films to patrons who show up to get off.

There were 4 other movie-goers in the house when cops busted Willard — 4 patrons in a dark, dank theater doing God knows what. It’s a safe bet they weren’t particularly offended. And if they say they were, good luck to them on cross examination.

So Willard had NO REASON to believe anyone there would get their nose out of joint by a little self knob-polishing … therefore, the lewd conduct law doesn’t apply to him. NOT GUILTY.

PBS has also reportedly fired Fred Willard from his job as the host and narrator of “Market Warriors.”

A statement from the network read, “Given the unfortunate news … effective immediately, Fred Willard no longer will be involved with the ‘Market Warriors’ series.”

PBS told their affiliates in an e-mail not to air any unaired episodes featuring Willard, and they’re already working on a new version of the show without Fred.

Mark Walberg, who hosts “Antiques Roadshow,” will be now be the voice on Willard’s episodes, PBS spokeswoman Jeanne Hopkins said.

The decision to drop Willard from the show came less than a day after the arrest, and Willard hasn’t been tried or convicted of anything.

“It’s something we felt was important to decide, and given the trust of our audiences, we wanted to move forward,” Hopkins said.