The Brazilian intended to quit F1 at the end of 2016 but returned to Williams after Valtteri Bottas moved to Mercedes following the retirement of world champion Nico Rosberg.
Massa, who has won 11 grands prix, says this time his decision is final.
The 36-year-old’s decision was influenced by the fact he wanted certainty on his future before his home grand prix next weekend.
“I agreed to return this season to help Williams when the call came,” he said.
“I have now enjoyed four great years with the team, but my career in Formula 1 will finally come to an end this season.”
He originally said he wanted to continue racing in F1 in 2018 but Williams are not yet ready to finalise their driver line-up for next year.
Massa, who achieved his biggest successes for Ferrari, added: “I take so many great memories with me as I prepare for my final two races in Brazil and Abu Dhabi, and although they will be emotional, I am looking forward to ending on a high note and preparing for a new chapter in my career.”
Williams deputy team principal Claire Williams said: “I would like to thank Felipe for all he has done for the team over the last four years. It has been an absolute pleasure to work with him.
“We are especially grateful that he agreed to postpone his retirement from F1 for a year, after Valtteri joined Mercedes, which demonstrated the depth of the relationship we built during our time together.
“We appreciate that it wasn’t an easy decision for him to return, after having such an emotional send-off at the end of last year. On behalf of [owner and team principal] Sir Frank, and all the team, we give our very best wishes to Felipe for the future.”
Williams are strongly leaning towards giving the seat alongside Canadian rookie Lance Stroll to Robert Kubica, who has not raced in F1 since suffering life-changing injuries in a horrific rally crash in February 2011.
But the team are taking their time to make their decision because of the length of Kubica’s absence.
He has only partial movement and atrophied muscles in his right arm and although the 32-year-old impressed Williams in two tests last month, there are inevitably unanswered questions as to whether he is strong enough to do a race distance at full pace on the toughest tracks.
Their reserve driver Paul Di Resta, Sauber racer Pascal Wehrlein and Red Bull reject Daniil Kvyat are also options. (Courtesy BBC)