Well, that didn’t take long: NBC announced late Friday night that it has picked up cop comedy “Brooklyn Nine-Nine” for a 13-episode sixth season, one day after Fox canceled the series and sparked a worldwide outcry from fans on social media.

As “Brooklyn Nine-Nine” trended worldwide on Twitter for hours after its cancellation, the producers were reportedly flooded with calls from other networks and streaming services. But this move makes sense, given that the show is produced by Universal Television, which shares a parent company with NBC.

Is your favorite TV show canceled? A guide to what’s renewed and what’s in trouble.

“Ever since we sold this show to Fox I’ve regretted letting it get away, and it’s high time it came back to its rightful home,” said NBC chairman Robert Greenblatt. “Mike Schur, Dan Goor, and Andy Samberg grew up on NBC and we’re all thrilled that one of the smartest, funniest, and best cast comedies in a long time will take its place in our comedy line-up.”

Co-creators Schur and Goor will continue as executive producers, and the entire cast will be back, including Samberg, Andre Braugher, Terry Crews, Melissa Fumero, Joe Lo Truglio, Stephanie Beatriz, Chelsea Peretti, Dirk Blocker and Joel McKinnon Miller.

This will be Schur’s third series on the network, along with “The Good Place” and recently ordered comedy “Abby’s”; he was also a co-creator on “Parks and Recreation” and executive producer of “The Office.”

After a roller coaster day of emotions, the producers and cast weighed in ecstatically on Friday night:

Read more:

Why ‘Brooklyn Nine-Nine’ fans are taking its cancellation so hard

If Brooklyn Nine-Nine does get canceled, the Sterling K. Brown episode is the perfect send-off

Opinion | Goodbye, “Brooklyn Nine-Nine.” And thank you.