NEW YORK — It's been the house of Muhammad Ali, Patrick Ewing and Billy Joel. Now, Madison Square Garden belongs to Harper Lee, too.

And to playwright Aaron Sorkin, director Bartlett Sher and the cast of Broadway’s smash-hit “To Kill a Mockingbird,” who, for an astonishing afternoon, took over the Garden and captivated an audience 18,000 strong.

That the attendees were mostly middle and high school students from all corners of New York City — invited to a free performance Wednesday of a heartbreaking stage version of Lee’s 1960 novel — made the event all the more remarkable. For this was the first time that the storied sports and entertainment arena had been transformed into a playhouse, for a one-performance-only run of a play. A production that also involved a specially made 90-by-40-foot stage, 105 stagehands and technicians and 18,000 free boxes of popcorn. Madison Square Garden chief executive James L. Dolan provided the arena and its in-house operations free of charge.

What a gift it made to a city and its young people, and what a thrill to bear witness to it. The kids, black and brown and white faces, in caps and hijabs and school sweats, sat in attentive delegations on all levels of the Garden through the nearly three hours of the play, which stars Ed Harris as Atticus Finch. Many of the students have been reading the novel, so, when Harris entered to thunderous applause, you wondered for a moment if they were clapping for the actor — or for the towering lawyer from fiction, called on to defend a black man in 1934 Alabama falsely accused of raping a white woman.

And if one entered the cavernous arena suspecting that 18,000 teenagers might view this as class-trip goof-around time, those suspicions evaporated with the extinguishing of the house lights. The students from Queens and Brooklyn, Manhattan, the Bronx and Staten Island laughed with the actors playing the young narrators: Nina Grollman as Scout, Nick Robinson as Jem, Taylor Trensch as Dill. There were gasps and rumbling murmurs at the racist rants of Neal Huff’s villainous Bob Ewell and Eliza Scanlen’s Mayella, the purported victim. Supportive applause erupted at the dignified protestations of Kyle Scatliffe’s Tom Robinson, the innocent defendant. And, wow — the deafening roar near the matinee’s end, when Harris got Huff around the neck, poised to pummel him. A cacophonous response at a volume I have never heard in a theater.

Their reactions pointed to one uncontestable truth: The kids were listening.

They were exhorted to strike this reflective posture by none other than Brooklyn-born film director Spike Lee, who took to the stage just before the show (along with New York Mayor Bill de Blasio and his wife, Chirlane McCray). “Please listen to the words,” Lee said, as he also offered encouragement to anyone in the crowd considering a life in the arts. McCray asked the teenagers to think about the advice they might give to Tom and to Scout; the mayor used the moment to remind the students of their collective political power.

“The only way to change your world,” de Blasio said, “is if you decide it is your world to change.”

The free performance was the brainchild of Scott Rudin, “Mockingbird’s” lead producer, who has said he was looking for ways for the play to reach a diverse young audience that might not otherwise get to see it. “Mockingbird” at the Shubert Theatre, like other Broadway productions, offers student matinees at discounted group prices. But the scale of this student matinee, at the ticket price of $0, made it truly one of a kind.

Though critics were asked not to review the event, I can’t imagine anyone would mind if I noted the extraordinary technical care that was taken to give the students an entirely “legit” experience. The amplification and camera work — with the performance projected onto four giant video screens — were superior. Sorkin’s script was performed in its entirety, scathing epithets and all. You could feel the collective bristle at some of the play’s language, and the collective release of tension when a touchstone character such as Lisa Gay Hamilton’s Calpurnia provided plain-spoken wisdom about the intractable racism of her fellow citizens.

From Harper Lee to Spike Lee, a sterling opportunity was seized by this play. Why not strive to make such showcases annual events, in cities across the country? This wasn’t just a harnessing of potential young people power; it was a demonstration of theater power. Playwrights: Please consider what you might create that could open the ears, all at once, of 18,000 teenagers. If you do, we surely won’t be writing epitaphs to the health and universality of this form.