Massa, who won 11 times in a career which will yield 250 starts, survived a horrific accident during qualifying at the Hungarian Grand Prix in 2009.
The Brazilian was struck on the crash helmet by a spring which came off Rubens Barrichello's car.
He suffered a fractured skull in the freak incident but miraculously he returned for the season-opening race in Bahrain the following year where he finished second.
Massa moved to Williams in 2014 after eight seasons with Ferrari.
'It is a very sad and emotional day and it is a big decision he has come to,' said deputy team principal Claire Williams.
'He is a true gentleman. The spirit he embodies really says everything about the man he is.
'We were so lucky that Felipe agreed to come and join us.
'Thank you for finishing your career at Williams.'