Having joined Williams in 2014, Massa has been instrumental in the team's improved performance in 2014 and 2015 supporting a resurgence to third place in the Constructors' Championship in his first and second years.
"Firstly, I am very happy to have an opportunity to return to Williams," said Massa. "I always intended to race somewhere in 2017, but Williams is a team close to my heart and I have respect for everything it is trying to achieve. Valtteri has a great opportunity, given the turn of events over the winter, and I wish him all the best at Mercedes.
"In turn, when I was offered the chance to help Williams with their 2017 Formula One campaign, it felt like the right thing to do. I certainly have not lost any of my enthusiasm for racing and I'm extremely motivated to be coming back to drive the FW40. The support from my fans over the last few weeks has been a huge boost and I'm grateful for that. I also look forward to working with Lance; I've known him for many years and seen his talent develop during that time, so I look forward to seeing what we can achieve together."
"I'm delighted that Felipe has agreed to come out of retirement to be a part of our 2017 campaign," added Claire Williams. "With Valtteri having a unique opportunity to join the current Constructors' Champions, we have been working hard to ensure that an agreement could be made with Mercedes to give Valtteri this fantastic opportunity.
"Valtteri has been part of the Williams family since 2010 and in that time has proved a huge talent, securing nine podium finishes. I would like to take this opportunity to thank him on behalf of the whole team, and wish him a successful season as he joins Mercedes.
"Felipe has always been a much-loved member of the Williams family, and having the opportunity to work with him again is something we all look forward to. He was always going to race somewhere in 2017, as he has not lost that competitive spirit, and it was important that we had a strong replacement in order for us to let Valtteri go. Felipe re-joining us provides stability, experience and talent to help lead us forward. He is a great asset for us."