Amazon has closed a $13 million deal for “Late Night,” a buzzy comedy about diversity in a late night talk show writers room that is written by, produced by, and stars Mindy Kaling. It is the first major sale out of the Sundance Film Festival.

“Late Night” co-stars Emma Thompson as a prickly comic who grudgingly takes an Indian-American writer (Kaling) under her wing after she is shamed into hiring more women and minorities. In a cover story for Variety, Kaling said that she saw “Late Night” as a chance to retell a familiar story of someone trying to break into the entertainment business from a fresh perspective.

“So much of this movie is about being a fan and being on the outside of the entertainment business,” Kaling told Variety. “That story has been told many, many, many times by 52-year-old white men, and I love all those movies. And as a comedy nerd I’ve always identified with them because it was the closest thing that I could identify with. There was no one like me making those kind of films.”

The film also hits as studios are being pressured to back more projects from women and people of color, making it particularly timely. The price represents the film’s ability to tap the zeitgeist. It is one of the largest pacts in Sundance history, falling short of the $17.5 million pact that Fox Searchlight made for “The Birth of a Nation,” but outpacing the $12.5 million that Netflix paid for “Mudbound” or the $12 million that Amazon paid for “The Big Sick.” Most of those deals were for global rights, which makes the “Late Night” sale, which is only for the U.S., a very rich one.

“Late Night” was originally set up at Fox 2000 with Paul Feig slated to direct the comedy. However, Kaling’s pregnancy and an illness in Thompson’s family resulted in the start date getting pushed. When cameras were finally ready to roll, Feig was making the Blake Lively thriller “A Simple Favor” and Fox 2000 had moved on. Instead, Kaling lined up independent financing and tapped Nisha Ganatra (“Chutney Popcorn”) to direct. Ganatra impressed Kaling with her personal connection to the material.

“I knew all about the power of holding the door open behind you instead of slamming it shut and saying, ‘Thank God I got in,’” she told Variety for the recent “Late Night” cover story.

The sale is a statement-maker for Amazon, which has not been active in recent film markets, having preferred to produce its own movies rather than rely as heavily on acquisitions. However, it also has a commercial zip to it that left some audience members at the film’s premiere on Friday comparing it to “The Big Sick,” another indie comedy that Amazon bought out of Sundance. The streamer would be thrilled if “Late Night” had similar commercial results. “The Big Sick” went on to gross $56.4 million globally when it hit theaters in 2017.

“Late Night” co-stars John Lithgow, Amy Ryan, and Ike Barinholtz.

CAA and 30WEST negotiated the sale with Amazon. 30WEST co-financed the movie with Film Nation.

RELATED VIDEO: