Viral video shows a Brooklyn man singing a song from “Willy Wonka and the Chocolate Factory” to shut down an anti-LGBT preacher who was haranguing subway riders.

The subway rider, later identified as Rob Maiale, said he was riding the M train to work when he encountered the self-styled preacher, who he had seen pestering other riders before.

The preacher was denouncing sex out of wedlock and then same-sex relationships, which the 28-year-old Maiale told Gothamist he found irritating but respected the man’s First Amendment right to express unpopular opinions.

ADVERTISEMENT

“I didn’t say anything, (but) once his ‘preaching’ shifted from an audience to an individual — a lesbian couple with a child — I decided that this guy wasn’t going to get to talk anymore,” said Maiale, a copywriter and voice actor.

He started singing “Golden Ticket” very loudly to drown out the preacher.

“What the man was saying was so absurd and hateful that I figured the most disarming thing would be something equally absurd and joyful,” Maiale said. “It’s a snapshot from my childhood that embodied joy, overcoming adversity — and candy.”

Police boarded the train shortly after another subway rider stopped recording video of the incident, and they escorted the preacher off after other passengers complained.

“I myself am neither religious, nor gay, but if you want to live in this city, you need to learn how to be civil,” Maiale said. “I’m not saying you have to like everything or everyone, but you do have to show respect.”

ADVERTISEMENT

Watch video of the incident posted online by Isaac Jaffe: