The 35-year-old Brazilian, who has won 11 grands prix, said it was the "right time" to finish his 15-year career.
Massa said: "I'm relieved and happy. You need to be strong enough to make decisions that are quite difficult."
The last race of the season in Abu Dhabi will be the 250th of Massa's career, in which he has driven for Sauber, Ferrari and Williams.
Massa took all his victories for Ferrari, for whom he drove from 2006 to 2013, narrowly missing out on the World Championship by one point to Lewis Hamilton in 2008.
He paid tribute to his former team-mate Michael Schumacher, whose decision to retire for the first time at the end of 2006, when the two were team-mates at Ferrari, was key to the continuation of Massa's career.
"I chose this place to announce my decision because 10 years ago Michael announced his retirement and the only way for me to continue at Ferrari was for him to stop," he said.
"So he chose to stop to give me the opportunity and here is almost my second country, which I love so much."
Massa's Ferrari career hinged on an accident at the 2009 Hungarian Grand Prix, when he suffered a fractured skull after being hit on the head by a suspension part from another car.
He had been Ferrari's team leader at the time, just edging team-mate Kimi Raikkonen on performance.
But Ferrari signed Fernando Alonso for the following season and Massa was immediately cast into a supporting role to the two-time world champion.
Massa said he had decided "some months ago" to bring his career to an end, adding he was "very proud" to have achieved so much in his career - "more than I ever expected".
"I managed to achieve my dream and I want to thank everyone who supported me throughout," he said.
Jenson Button is among the drivers the team are interested in signing to replace Massa, along with Force India's Sergio Perez.
Button, who is not expected to be retained by McLaren beyond the end of this season, has not made clear whether he wants to continue in F1 or not.
Subscribe to the BBC Sport newsletter to get our pick of news, features and video sent to your inbox.
Williams driver Felipe Massa has announced he will retire from Formula 1 at the end of the season.