NBC has rescued acclaimed but low-rated comedy Brooklyn Nine-Nine, a day after Fox canceled the series, sparking a fan outcry on social media.

The series, wrapping up its fifth season May 20, will return for 13 new episodes (down from 22 on Fox), but likely won't resurface until early 2019. NBC's Universal Television owns the comedy, which stars Andy Samberg and Andre Braugher and is set in a police precinct, so extending it figures to increase profits on the show and give the network some goodwill among comedy fans of its like-minded Superstore and The Good Place, whose creator, Michael Schur, also created Brooklyn along with Dan Goor. Schur will have a third show due on NBC next season, a comedy called Abby's. The main actors remain under contract, despite the move.

The cast and producers tweeted simultaneously about the news at midnight ET Friday; NBC will announce its schedule Sunday and unveil it to advertisers Monday at Radio City Music Hall.

Schur, who tweets as @kentremendous, wrote "This happened because fans of the show went berzerk (sic). We can't thank you - or @NBC - enough. #Brooklyn99

This happened because the fans of the show went berzerk. We can't thank you -- or @NBC -- enough. #Brooklyn99

#Brooklyn99 IS COMING BACK FOR SEASON 6 YOU GUYS ON NBC!!!!! You did this!! You got loud and you were heard and you saved our show!! Thank you!! Thank you to NBC!! NINE NINE!!!!! pic.twitter.com/cTycfF4FoR

Chances were fleeting for saving the series, which performed well in USA TODAY's Save Our Shows poll. Hulu licenses reruns, but declined to make its own offer Friday to buy new episodes as it did for The Mindy Project, another NBC-owned comedy canceled by Fox. Netflix also reportedly passed on the series. But fans including Hamilton creator Lin-Manuel Miranda, singer Josh Groban and director Guillermo del Toro (The Shape of Water) tweeted pleas to save it.

“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 Entertainment chairman Robert Greenblatt, in a statement. “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 lineup."

The current season will finish its Fox run on May 20, when Jake (Samberg) marries Amy (Fumero).

Posted!

A link has been posted to your Facebook feed.

Last year, fans banded together and voted to try and save NBC's "Timeless." The result? A win in USA TODAY's 20th annual Save Our Shows poll helped reverse the show's cancellation by NBC. So which series could get a reprieve this season? Here are your votes for the shows you want saved, and dropped. Paul Drinkwater, NBC