Can a deliriously funny comedy also break your heart? This year’s winner of the Grand Jury Prize and Audience Award at Sundance proves that it can. Alfonso Gomes-Rejon’s “Me and Earl and the Dying Girl,” following two high school misfits guilted into hanging out with a classmate with leukemia, is tremendously inventive storytelling. Since 2010, three Sundance winners have been nominated for the best picture Oscar. This one, crackling with heart, spirit and love of the movies, is a strong contender for the fourth.

Balancing heavy and light comes naturally to Gomes-Rejon. A native of Laredo, Texas, he has directed multiple episodes of TV’s polar opposites “American Horror Story” and “Glee.” He made his feature debut last year with the horror thriller “The Town That Dreaded Sundown.”

“Slasher films are certainly quite hysterical with the fake blood and whatnot,” he said during a recent interview. “I like to explore different genres and try different things.”

He learned the value of that versatility by beginning his career by assisting Martin Scorsese after film school. “Scorsese can make ‘Kundun,’ he can make ‘Cape Fear,’ he can make ‘Mean Streets’ and ‘Casino.’ I would still be there today gladly bringing him his coffee just to be exposed to his knowledge of film history.”

Which explains the wealth of allusions to Scorsese and dozens of famous global filmmakers throughout “Me and Earl.” It’s a rare populist movie that packs classic cinema lovers’ references beside parody remakes such as “Rosemary Baby Carrots” and “The Janitor of Oz.”

“All these heroes that I’ve known and mentors I’ll never know are in there as a way for me to celebrate them,” Gomes-Rejon said.

The film richly crosses age lines, combining its millennial troupe with comedy veterans such as Molly Shannon, Nick Offerman, Jon Bernthal and Connie Britton. “Comedians often make the greatest dramatic actors,” he said. “Look at the cast of ‘Casino,’ which I was production assistant on with Scorsese. There’s Alan King, Dick Smothers, Don Rickles, Steve Allen, Kevin Pollak. I love that. It’s very unexpected, but they can go deep, boy.”

Several key scenes were improvised as long dialogue shots, including a six-minute conversation between the young stars Thomas Mann (“Project X”) and Olivia Cooke (from TV’s “Bates Motel”).

“That shot was just right, to hold it looking up at her like this Renaissance sculpture. She seems towering and massive and adult and strong and focused as she makes a very adult decision. And he seems so small and childlike. I didn’t want to touch it, the performances were so flawless I didn’t want to fabricate that moment with additional takes. It’s terrifying to walk away at that point because if it doesn’t work, you’re stuck with it. I was at Olivia’s feet with my assistant director. I couldn’t say ‘Cut’ because I had a lump in my throat. And he couldn’t say ‘Cut’ either. Moments like that are terrifying but invigorating.”