The Williams team has confirmed Felipe Massa will race alongside Lance Stroll in the 2017 Formula 1 season, replacing Mercedes-bound Valtteri Bottas.
Massa, who had announced his retirement from the sport at the end of the past season, will thus continue racing for another year with the Grove-based squad.
Williams said the deal was for one year.
The team also confirmed Bottas has been released to join Mercedes.
The 35-year-old Brazilian was convinced to return to racing as Williams wanted an experienced driver to partner rookie Stroll in a season with big regulation changes.
"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 1 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."
Bottas had a contract with the team for this year, but the Finn will leave the squad to replace world champion Nico Rosberg at Mercedes.
An official announcement is expected later today.
Massa, who has 250 grand prix starts to his name, finished the 2016 season in 11th position, three places and 32 points behind Bottas.
Claire Williams added: "I'm delighted that Felipe has agreed to come out of retirement to be a part of our 2017 campaign.
"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."
"A new challenge" - Sauber signs Pascal Wehrlein for 2017 F1 season
Completing the F1 2017 driver puzzle – Felipe Massa stays on at Williams, Valtteri Bottas moves to Mercedes
Massa returns to F1 as Bottas replacement
- Formula 1