Hit comedy cop show Brooklyn Nine-Nine has been revived by US network NBC just a day after rival Fox sparked outrage among fans by cancelling it.
The show, which follows a team of New York City detectives in Brooklyn's 99th Precinct, was one of the longest-running comedies on Fox and boasted a stellar rating on the renowned reviews aggregator website Rotten Tomatoes.
But Fox announced on Thursday that it would put an end to the series after five seasons.
Fans quickly started a social media campaign to save the show, which premiered in 2013, and enjoyed support from several famous faces, including Oscar-winning director Guillermo del Toro, who described its cast of characters as "beautiful, powerful, flawed" and "fully human".
Now NBC has announced that it has picked it up for a sixth season of 13 episodes, to air in May 2019.
"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.
"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."
The show features a diverse cast led by Andy Samberg, Andre Braugher, Stephanie Beatriz, Terry Crews and Melissa Fumero. Many of the stars thanked the fans who campaigned to save the show.
Beatriz tweeted: "SQUAD YOU DID IT #BROOKLYN99 WILL BE ON NBC FOR OUR 6th SEASON!"
And her co-star added: #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!!!!!"
More from Entertainment
The series has been praised for its positive representation of ethnic minorities and the LGBT community, and it has been recognised with wins at the Golden Globes and the Emmy Awards.
The fifth season is currently airing on E4 in the UK, but a network for the sixth season has not been confirmed.