On a recent evening in downtown Manhattan, a capacity crowd gathered at the Cherry Lane Theater to see SleepOver, the debut work of Max Friedlich. Before the curtain rose, the playwright sheepishly greeted his fans at the door, wearing a baseball cap and shuffling his feet. There is one more thing you should know about Mr. Friedlich: he’s 17.

Friedlich is the youngest writer to present at this year’s New York International Fringe Festival, the annual showcase and breeding ground for accomplished stage performance.

In SleepOver, we meet Matt, a sophomore and our neurotic protagonist. His classmate, Theo, shows up at his house uninvited and starts crashing on his couch. Both the boys are from upscale families—but Matt is white and Theo is black.

What follows is a 90-minute exploration of race, love, and high-school lust. If you hadn’t met the playwright, you wouldn’t know this is the work of an actual high-school student. It sounds like a writer who expertly captures the voice of a tweeting, Facebook-posting generation. OK, maybe there’s one clue: the racy dialogue.

Matt: “Sorry I was just an asshole right now. I’m a gigantic, bleeding, heartbroken gooch.”

Theo: “What the fuck’s a gooch?”

Matt: “It’s the thing between your ass and balls.”

When I tell Max, later, that I wasn’t familiar with the word, he helpfully explains that he picked it up from Jackass, the Johnny Knoxville series on MTV with X-rated stunts that are forever immortalized on YouTube. After spelling the word for me, the boys—Max and his leading actors—offer a few other variations.

A synonym for gooch, they say, is “taint.”

“The way I was taught it was ‘underball,’” says Jared Kemp, 18, who plays Theo.

Friedlich learned of his play’s acceptance into the Fringe Fest in an email last spring. Later that day, he went to his biology class and botched a test, because he was so distracted.

He balanced rewrites against studying for classes at Friends Seminary, a Manhattan private school. The play was directed by an adult, who toned down a pivotal sex scene near the end between two of the four characters, despite Friedlich’s protests.

“In the stage direction, they almost have sex on stage … there was a lot more fondling,” Friedlich says. “It’s been such a great learning experience, seeing what’s ambiguous in the script and what a director can change around because it’s not specified.”

Hollywood tends to worship youth, but only when adults are handling the puppet strings. That was the case this summer, when 29-year-old Andrew Garfield played a high-school version of Peter Parker in the new Spider-Man. Friedlich cites other works he’s recently seen where the young characters sound twice their age. “It’s, like, give me a fucking break,” he says.

As he nibbles on a fruit salad over breakfast, Friedlich cites a long—not just for a teenager—list of playwrights who have inspired him, including Kenneth Lonergan, Neil LaBute, and Conor McPherson. His father, Jim, is a media executive. His mother, Melissa Stern, is an artist and “her work is very dark. I think I gravitate toward darker things,” Max says.

Even so, the darkness is mixed with a lot of humor. “He’s very funny,” says Andrea Lepcio, a New York playwright who teaches at Young Playwrights. “I would have given anything to have written the line about LeBron James’s dick. That line is brilliant, and it’s not the only brilliant line in the play.”

“There are tidal waves of laughs,” says Brandon Reilly, 20, who stars as Matt. “When we did the show in front of an audience, we realized how funny the writing was. Some of the lines that we were throwing away, people were erupting over.”

The New York Daily News spotlighted Max’s play this month, calling him a “junior achiever.” The play also has been controversial. Two critics have accused the play of being homophobic for its repeated use of the word “faggot.”

Max doesn’t agree. “There’s no denying that young straight men and youth culture uses the word ‘gay’ as a synonym for stupid,” he says. “I’m still opposed to the usage of that in conversation, but these are characters on stage and I’m a writer.”

Friedlich’s career in theater started when he was 12. That’s when he was cast as Rumpelstiltskin in a local production of Once Upon a Pandora’s Box. It wasn’t exactly a pleasant experience. “I had a lot of trouble with it,” he says. “I was kind of a fat little kid. I didn’t have a lot of confidence in myself or my ability. One day in rehearsal, I giggled while I was talking. The assistant director said, That’s great, you should do that. So the whole time, I was this maniacal fat kid, giggling.”

He discovered he preferred writing to acting, because “I didn’t want to feel uncomfortable or used,” he says. In the seventh grade, he directed an abridged version of A Midsummer Night’s Dream. In the eighth grade, he wrote a play about Jesus meeting a prostitute in a bar in upstate New York. His teacher was thrilled and encouraged him to keep going.

So began the summer and afterschool workshops. He was accepted into Stephen Sondheim’s Young Playwrights Program and the Powerhouse Apprentice Program at Vassar College. He got the idea for SleepOver when he was 15. He says the character of Matt is, in a way, his doppelganger. “He’s very similar to me, sophomore year,” Friedlich says. “He represents everything about myself that I didn’t like that year. I went through my first real breakup. I got so bitchy and so obnoxious. I really did annoy myself.”

At the start of the play, Matt is happy with his girlfriend until (true to Max’s real life) they abruptly break up. This prompts the two male characters to launch into a lively discussion about women. Put another way, a friend of Max’s counted the number of times the word “fuck” appears in SleepOver. Max estimates it’s “between 122 and 128, depending on what Jared and Brandon add.”

Max is already working on a second play called Black Ice, about “selfishness and religion. It’s two characters onstage, one is grilling the other one, and you don’t know why.” But his next big project is starting his senior year in high school. The last performance of SleepOver is on Saturday night (see here for tickets).

As the play came to its bittersweet, hysterical, and slightly de-sexualized climax, the audience fought back laughter and tears. The woman seated next to me had a special glow. She wasn’t just a member of the audience. She was also Max’s mother, Melissa, who has offered regular, critical notes on the play. Max said she shares some similarities with the mom character onstage.

But as the lights went up, she insisted: “That’s not our family!”