NBC has saved the day for Brooklyn Nine-Nine fans. Both Andy Samberg and Stephanie Beatriz confirmed the exciting news on Twitter Friday night.

"SQUAD YOU DID IT #BROOKLYN99 WILL BE ON NBC FOR OUR 6th SEASON," Beatriz tweeted.

SQUAD YOU DID IT #BROOKLYN99 WILL BE ON NBC FOR OUR 6th SEASON! — Stephanie Beatriz (@iamstephbeatz) May 12, 2018

"So happy to announce: NBC IS PICKING UP BROOKLYN 99 for SEASON 6," Samberg tweeted on his Lonely Island Twitter page.

So happy to announce:

NBC IS PICKING UP BROOKLYN 99 for SEASON 6!!! — The Lonely Island (@thelonelyisland) May 12, 2018

"Hey everyone, just wanted to say no big deal but.... NBC JUST PICKED #BROOKLYN99 UP FOR SEASON 6," co-creator Dan Goor tweeted. "Thanks in no small part to you, the best fans in the history of the world! Nine-nine!!!!!!!!!"

Hey everyone, just wanted to say no big deal but....

NBC JUST PICKED #BROOKLYN99 UP FOR SEASON 6!!!

Thanks in no small part to you, the best fans in the history of the world! Nine-nine!!!!!!!!! — Dan Goor (@djgoor) May 12, 2018

Melissa Fumero, who stars as Amy, also confirmed the news on Instagram.

"#Brooklyn99 IS COMING BACK FOR SEASON 6 ON NBC!!!!! You guys did this," Fumero wrote. "You got loud and you were heard and we are forever grateful to you for doing so!!! Thank you to NBC for giving us the opportunity to finish this special show!! NINE NINE!!!!!!"

The surprising news came just hours after it was clear that Hulu would not save the series, which was cancelled by Fox on Thursday. Hulu was thought to be a frontrunner, since it is the streaming home of the series. The company also previously saved The Mindy Project from cancellation.

NBC began showing interest in keeping the show alive after seeing the outpouring of fan support after Fox cancelled the show. Since the series is produced by NBC's sister company Universal TV, it was easy for the peacock to fly in and keep it alive.

This is the second show this week to be revived by one network after a rival cancelled it. Fox picked up Tim Allen's Last Man Standing, which was off the air for a year after ABC cancelled it in 2017. The show is a 20th Century Fox TV production.

Brooklyn Nine-Nine should be a perfect fit at NBC. Not only is the series headlined by a former Saturday Night Live star, Andy Samberg, but it was also created by Parks and Recreation's Goor and Mike Schur.

Nine-Nine won two Golden Globes for its first season. Andre Braugher, who plays Captain Holt, earned three Emmy nominations.

There are just two episodes left of the fifth season, which ends with Amy and Jake (Samberg) getting married. "White Whale" airs on Sunday, May 13 at 8:30 p.m. ET and "Jake & Amy" airs on May 20.