Mark Webber was also linked to the move before he confirmed his commitment to Red Bull earlier this week.
This means that Ferrari will have unchanged like up till the year 2012, as Massa's team-mate Fernando also has his contract till 2012.
The Brazilian has been with Ferrari team since 2001 but his future was coming under scrutiny after his poor form and expiration of his current contract at the end of this year.
Massa, who recovered from shocking head injuries he sustained midway through 2009, said: “I am happy to be given the opportunity to drive for Ferrari for a further two seasons."
“Throughout my entire Formula One career, I have always raced with an engine made in Maranello. And it is a matter of pride for me to be able to continue working with a team that I regard as a second family," he added.
Team principal Stefano Domenicali said: “Felipe has been part of Ferrari for almost a decade. Together with us he has grown as a driver and as a man, going through some very difficult times as well as giving us moments of great happiness.
“We wanted to show proof of stability for the future, believing in the worth of a driver pairing that is without equal in terms of talent, speed and its ability to work together for the good of the team," he added.