Gene Wilder was terrific when he was calm and collected. But when he lost it, he was transcendent.

Often playing opposite enormous, big performers like Zero Mostel and Richard Pryor, Wilder was a straight man who often wound up in a straight jacket. His enormous range was everything in between: from a quiet sweetness to a madcap lunacy.

Wilder died Sunday in Stamford, Connecticut, from complications of Alzheimer’s disease at age 83.

With wild, Harpo-like hair, a melancholy face and a mad glint in his eye, Wilder was an earthquake of neuroses that tremored with blinks and sweat before cracking and quivering in hysteria.

“I can’t stop! I’m hysterical!” he screamed as Leo Bloom in “The Producers” when the well-planned flop refused to flop. His partner (Mostel) tries to calm him by throwing a glass of water in his face. A beat. “I’m wet! I’m wet! I’m hysterical and I’m wet!”

Born Jerome Silberman in Milwaukee, Wilder first began performing for his mother, who was badly marred by a heart attack when Wilder was six, as a way to entertain and cheer her up. He would later be schooled by Lee Strasberg at the Actor’s Studio, but that early aura — of laughter with darkness around— never left Wilder.

“Come with me and you’ll be in a world of pure imagination,” he sang in “Willy Wonka & the Chocolate Factory.” His Wonka was at once iconic and impossible to pin down. His combination of charm and whimsy, darkness and strangeness breathed life into Roald Dahl’s tale. His Wonka was too much for initial audiences (the film was a box-office disappointment) but grew to be adored for its off-kilter complexity.

“I’m an actor not a clown,” Wilder was fond of saying.

His early big-screen roles were feats of lunacy: the kidnapped undertaker of “Bonnie and Clyde,” the doctor who falls for a sheep named Daisy in Woody Allen’s “Everything You Wanted to Know About Sex.”

“My quiet exterior used to be a mask for hysteria,” he told Time magazine in 1970. “After seven years of analysis, it just became a habit.”

Wilder’s bug-eyed knack for neurotic extremes, though, was only so winning because of his underlying tenderness. Fully embodying his characters, Wilder was utterly unpredictable, moment to moment.

In Mel Brooks’ “Young Frankenstein,” in which he plays Dr. Frankenstein, might be his greatest performance: a mad scientist with his own demons and an acute sensitivity to the pronunciation of “Frankenstein.” He and the monster, in tuxes, singing and dancing to “Putting on the Ritz” might sum up Wilder, in all his bizarre glory, more than any other scene.

He could be sentimental, too. The title of his 2005 memoir, “Kiss Me Like a Stranger,” came from his then-late third wife, Gilda Radner, whom he met while filming 1982’s “Hanky Panky.” It was a phrase Radner would say to him, its meaning mysterious to Wilder. He acted rarely after her death in 1989.

Wilder was much more than a comic actor, too. He was a screenwriter (he co-wrote “Young Frankenstein” with Mel Brooks), a director of four films, a novelist and a stage actor. He met Brooks through Anne Bancroft, with whom he starred in the Brecht play “Mother Courage.”

Their collaboration together — “Blazing Saddles,” ”Young Frankenstein,” ”The Producer” — constitutes one of the great pairings in comedy. Wilder and Pryor, too, were an exceptional duo, albeit with more mixed results: “Stir Crazy” and “Silver Streak” as well as the lesser “See No Evil, Hear No Evil” and “Another You.”

Wilder, who shied away from interviews, remained delightfully enigmatic through his many decades in show business. We knew his characters better than him.

“Time is a precious thing. Never waste it,” he told Veruca Salt in “Wonka,” before tossing a clock into bubbling tub.