Rosberg, in a Facebook page revealed he made the decision on Monday, a day after winning the 2016 F1 title.
"I took my decision on Monday evening. After reflecting for a day," the German said in a statement on his Facebook page, which said he wanted to devote more time to his family.
"The only thing that makes this decision in any way difficult for me is because I am putting my racing family into a tough situation."
Rosberg's retirement has left motor racing stunned and Mercedes looking for a new teammate for Lewis Hamilton.
The 31-year-old German, who finally beat off Hamilton for the F1 title last Sunday, is the first reigning champion to retire since Alain Prost in 1993.
Rosberg made the bombshell revelation in Vienna ahead of the International Automobile Federation (FIA) annual awards ceremony.
"I have decided to end my Formula One career here," said Rosberg, who finished second to Hamilton in Abu Dhabi to beat the Briton to the world drivers' crown by five points.
Rosberg, who had previously given no indication that he was about to quit, said he made the decision in the aftermath of his championship triumph.
"I didn't know if I had the balls and I took a bit of time," he said.
"But I am done. End of story. And the next step is being a dad and a husband and I am very much looking forward to that."
Hamilton, who was in go-karting with Rosberg when they were teenagers before their relationship soured at Mercedes, said he was not surprised.
"We started out when we were 13 and we'd always talked about being champions," the Briton, who lost his world title to Rosberg, told autosport.com in Vienna.
"It's going to be very, very strange and it will be sad not to have him in the team next year. The sport will miss him and I wish him all the best."
Rosberg takes his leave of F1 with 23 race wins and 30 pole positions, relinquishing life in the fast lane to spend time with his wife, childhood sweetheart Vivian Sibold, with whom he has a daughter, Alaia, born in August last year.
Mercedes team boss Toto Wolff, who now faces the task of finding a suitable successor to Rosberg, said: "For the team this is an unexpected situation and an exciting one.
"This is a brave decision by Nico and testament to the strength of his character.
"He has chosen to leave at the pinnacle of his career, as world champion, having achieved his childhood dream."
In capturing the title Rosberg emulated his father Keke, who won the F1 crown in 1982.
Rosberg began karting aged six. He and Hamilton met as rivals in 1997 and became team-mates in 2000.
In 2002, he moved to the German Formula BMW championship and won the title.
Rosberg arrived in F1, with Williams, via the Formula 3 Euro Series and winning the inaugural GP2 title in 2005.
Before joining Williams, he turned down a place at Imperial College, London to study aeronautical engineering.
Rosberg claimed his first podium at the 2008 Australian Grand Prix, sharing the moment with a victorious Hamilton, who had arrived in F1 with McLaren a year earlier.
In 2010, he moved to the rebranded Mercedes team created by the German manufacturer's takeover of the 2009 champions Brawn.
He recorded consistent finishes as team-mate to returning Michael Schumacher before the seven-time champion?s final retirement and the arrival, in 2013, of Hamilton.
Their partnership ignited the team's spell of dominance. Though Hamilton beat him to be champion in 2014 and 2015, the methodical Rosberg finally took the crown in 2016.
In a message to his fans on social media, Rosberg wrote: "Since 25 years in racing it has been my dream, my 'one thing' to become Formula One World Champion. Through the hard work, the pain, the sacrifices, this has been my target.
"And now I've made it. I have climbed the mountain, I am on the peak, so this feels right."
Mercedes say they will start the search for his replacement next week, with one name already being bandied about -- Mercedes' reserve driver Pascal Wehrlein, who drove for Manor in his debut season in 2016.
Rosberg is the second world champion to quit this year after 2009 title winner Jenson Button. Brazilian veteran Felipe Massa has also retired.