In one of the biggest deals in the history of Sundance, Amazon Studios has landed distribution rights to “The Big Sick” for about $12 million, Variety has learned.

The pact comes on the heels of the romantic comedy’s rousing premiere on Friday night. The film is about a Pakistani-American comedian (Kumail Nanjiani) whose relationship with his girlfriend (Zoe Kazan) is nearly derailed over cultural differences and a health crisis. Nanjiani co-wrote the heavily autobiographical script with his wife Emily V. Gordon.

The negotiations for North American rights and other foreign territories stretched into midnight on Saturday. Nanjiani told Variety earlier this week that he wanted the film to get a theatrical release. Unlike Netflix, its rival streaming service, Amazon is a big proponent of the theatrical experience, with all of its films getting at least some kind of theatrical run.

“The Big Sick” sparked interest from a number of distributors, among them Sony, Focus Features and Netflix. At least some of these studios presented final bids on Saturday. The comedy, which earned glowing reviews, is considered one of the most commercial films at this year’s festival. Other territories were pre-sold, which was a concern to some potential buyers.

Michael Showalter (“Hello My Name is Doris”) directed the film with Judd Apatow and Barry Mendel producing. Holly Hunter, Ray Romano, Bo Burnham, Aidy Bryant, and Kurt Braunohler round out the cast.

There have already been a number of high-profile sales at this year’s Sundance. Netflix bought the documentaries “Casting JonBenet” and “Chasing Coral,” and teamed with Momentum Pictures to acquire “Fun Mom Dinner”; A24 nabbed “A Ghost Story,” a drama with Casey Affleck; and Sony Pictures Classics picked up the gay love story “Call Me By Your Name.” “Mudbound,” a drama about life in the segregated South, premiered to a thunderous standing ovation on Saturday. It is expected to spark another epic bidding session.

Amazon was very active at last year’s Sundance, buying the likes of “Gleason,” “Weiner-Dog,” and “Manchester by the Sea.”

FilmNation and UTA negotiated the deal.