LOS ANGELES — NBC has picked up "Brooklyn Nine-Nine" for a sixth season, the network announced Friday.

The decision comes after the cop comedy was canceled at Fox after five seasons on Thursday. Producer Universal Television had been in talks with Hulu to keep the series afloat, but the streaming service ultimately passed.

The sixth season will consist of 13 episodes.

Fans of "Brooklyn Nine-Nine" were stunned when Fox announced they were cancelling it along with fellow comedies "The Mick" and "The Last Man on Earth." There has been a large online push to save the show, with celebrity fans like Lin-Manuel Miranda leading the charge by sharing hashtags like #SaveB99 and #RenewB99. Mark Hamill also expressed his dismay at the show's cancellation in a tweet on Thursday.

Oh NOOOOOOOOO!!!!!!!!! I'm SO not ready to say #ByeBye99. Be forewarned @FOXTV-when networks dump shows I love, I'm known for holding grudges a long, L-O-N-G time. I'm still mad @CBS didn't renew #SquarePegs! #EverythingILikeGetsCancelled https://t.co/NEry6Hrpng — Mark Hamill (@HamillHimself) May 10, 2018

"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 Robert Greenblatt, chairman of NBC Entertainment. "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. I speak for everyone at NBC, here's to the Nine-Nine!"

With the move, series executive producer and co-creator Schur will have three shows on NBC for the 2018-2019 season. Along with "Brooklyn Nine-Nine," NBC also airs the critically-acclaimed single-camera comedy "The Good Place" and will air the recently-ordered multi-cam "Abby's," about an unlicensed bar in San Francisco. It will also mark a homecoming of sorts for Samberg, who was previously a cast member on "Saturday Night Live."

Good news: Andy is back on NBC!!!

Bad News: Andy has SO many unpaid NBC parking tickets!!! https://t.co/Mti5aWNBbr — Seth Meyers (@sethmeyers) May 12, 2018

The cast includes Samberg, Andre Braugher, Terry Crews, Melissa Fumero, Joe Lo Truglio, Stephanie Beatriz, Chelsea Peretti, Dirk Blocker, and Joel McKinnon Miller.

Schur, Goor, David Miner and Luke Del Tredici executive produce. Universal Television, Fremulon, Dr. Goor Productions, and 3 Arts Entertainment produce.