The Brazilian confirmed the end of his eight-year spell at the Italian outfit
, saying: "From 2014 I will no longer be driving for Ferrari."
Raikkonen's deal is said to have been completed on Monday and could be announced imminently.
The Finn, 33, will join Fernando Alonso, world champion in 2005-6.
Massa, who has made 184 starts for Ferrari - winning 11 races - since joining them in 2006 from Sauber, added: "I would like to thank the team for all the victories and incredible moments experienced together.
"Right now I want to push as hard as possible with Ferrari for the remaining seven races. For next year, I want to find a team that can give me a competitive car to win many more races and challenge for the Championship which remains my greatest objective."
Ferrari had been weighing up whether to bring back their 2007 world champion Raikkonen, sign the promising Sauber driver Nico Hulkenberg or retain Massa, who has performed inconsistently as Alonso's team-mate.
The Ferrari team had wanted to replace Massa with someone who would provide more reliable performance, and have for some time considered Raikkonen to be the best candidate.
Raikkonen wins world title in Brazil
The Finn had the option to remain at Lotus but the team were unable to provide him with the reassurances he requested that they had the technical and financial resources to compete at the front next year.
They have lost their highly rated former technical director James Allison to Ferrari and there have been delays paying Raikkonen's salary this year.
Raikkonen's return would mean Ferrari are re-employing a driver who they paid off at the end of 2009, a year before the end of his contract, to make way for Alonso.
At the time, the team preferred to keep Massa. The Brazilian had out-scored Raikkonen on points in 2008 and through 2009 until he suffered a fractured skull in an accident at that year's Hungarian Grand Prix.
Although there were question marks about his recovery, the team felt they could not cast the Brazilian adrift in the circumstances.
But he has been inconsistent for the last few seasons and the Ferrari team believe Raikkonen will provide more consistent support for Alonso and prevent any possibility of the Spaniard not producing his best.
In a Q&A with fans on his Twitter account on Monday, Alonso said: "I said yesterday to the media it's not possible for me to talk of any name for next year because I have a lot of respect for Felipe.
"We've been working very hard and close for four years to give Ferrari the maximum.
"Whatever decision the team will take will be good for me and we will keep working to give Ferrari the best results possible."
Lotus are expected to replace Raikkonen with Hulkenberg, who starred at the Italian GP with a third place on the grid for Sauber and a fifth-place finish.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.