Image copyright Channel 4/Universal Television Image caption Brooklyn Nine-Nine was launched in 2013 and has gained a large following

US network NBC has picked up Brooklyn Nine-Nine, just one day after Fox announced it was cancelling the cult comedy.

The decision to end the series had sparked outrage among fans and celebrities alike.

The 13-episode sixth season will air next year.

Brooklyn Nine-Nine follows a team of detectives in the New York City Police Department and has been praised for its inclusivity and diversity.

Following Fox's decision to axe the series, fans quickly launched a social media campaign calling for it to be renewed, with the hashtag #Brooklyn99 used over 650,000 times on Twitter.

Celebrities including the Backstreet Boys and director Guillermo del Toro weighed in with messages of support.

The series' actors and writers credited fans for NBC's decision to save the series.

Actress Melissa Fumero, who plays Amy Santiago, shared celebratory gifs from the show, while Stephanie Beatriz, who appears as Rosa Diaz, thanked viewers.

In a statement, NBC Entertainment's Chairman Robert Greenblatt said: "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."

Brooklyn Nine-Nine had been one of the longest-running comedies on Fox, with a 100% critics' rating on Rotten Tomatoes, as well as a 95% audience score.

The fifth season is currently being shown on E4 in the UK. The season finale will air on 20 May in the US.