The Brazilian, who had earlier been informed of Ferrari's decision and has driven for the Italian outfit since 2006, said: "From 2014 I will no longer be driving for Ferrari.
"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!"
Massa came agonisingly close to winning the title in 2008, when he won the Brazilian Grand Prix, only to be deprived of the championship when Lewis Hamilton moved up into the fifth place he required on the penultimate corner of the last lap.
He has been linked with a move to Lotus, who are also considering Sauber driver Nico Hulkenberg, another man who was in the frame at Ferrari before they decided on Raikkonen.
The decision to partner Alonso with Raikkonen is a dramatic change in philosophy by Ferrari, who have previously operated with a clear number one driver, both with Michael Schumacher from 1996-2006 and then with Alonso for the last four years.
Ferrari have now decided that having two lead drivers will be a more effective way of securing success - this was their policy when Raikkonen and Massa were team-mates in 2007-9.
Best championship position:
The decision will be interpreted in some quarters as a snub to Alonso, but the Spaniard has been told of Ferrari's decision and is said to have accepted it.
The partnership and rivalry between the two men will be eagerly anticipated - Alonso and Raikkonen are widely recognised as two of the four best drivers in the world, along with Mercedes' Lewis Hamilton and Red Bull's Sebastian Vettel.
Alonso's relationship with McLaren, when he was team-mates with Hamilton in 2007, was famously turbulent, and the ructions led to him leaving the team just one year into a three-year contract.
Alonso has since made it clear that his problems at the time were not with Hamilton but with the team not delivering on promises that had been made to him about his status.
Ferrari wanted to replace Massa with someone who would provide more reliable performance and have for some time considered Raikkonen to be the best candidate.
But the decision needed to be approved by Ferrari president Luca Di Montezemolo.
Raikkonen 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 is the first driver to return to Ferrari after a previous spell since Austrian Gerhard Berger re-joined them in 1993 after leaving them at the end of 1989 to join McLaren.
Kimi Raikkonen interview leaves BBC cold
When Raikkonen left Ferrari at the end of 2009 he still had one year on his contract, but the team needed to get rid of either him or Massa to make space 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.
Ferrari, having employed Raikkonen as the man they expected to take over from Michael Schumacher, also felt that the Finn had not shown the required leadership. They felt Alonso's more forceful nature would give them what Raikkonen had not.
But tensions have grown between Alonso and Ferrari this year after narrowly missing out on winning the title in both 2010 and 2012.
Now, Ferrari believe Raikkonen will provide more consistent support for Alonso and prevent any possibility of the Spaniard not producing his best.
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.