Felipe Massa will stay at Ferrari for the 2013 season after signing a one-year extension to his current contract.
However, it is only thought to be a stop-gap deal before the expected arrival of Sebastian Vettel in 2014.
Massa, 31, had a poor start to the season but a resurgence in form secured an eighth successive season at Ferrari for the Brazilian.
Ferrari boss Luca di Montezemolo said Massa was "back at a high level", adding "I expect a lot from him".
Massa said: "I want to thank president Montezemolo and [team principal] Stefano Domenicali, who gave me confidence which I have always maintained, even in the most difficult moments."
The Brazilian's future at the Italian team was uncertain after a poor start to the season which saw him struggle to make the final part of qualifying and subsequently challenge for points during races.
But an improvement in form since in the Belgian Grand Prix, including his first podium in 35 races at the Japanese Grand Prix earlier this month, has saved his drive.
Domenicali added: "He has shown, especially in the latter part of the season, to be competitive at the highest level, as we expect from every driver behind the wheel of a Ferrari.
"We have always supported Felipe, even in the most difficult moments of his career. We are confident of its value, and that he will repay the trust that has been renewed."
Alonso tweeted: "I am so happy to continue another year with @Felipe1Massa as a team-mate! I'm sure we are the best team! #ForzaFerrari
"After eight different teammates.. Felipe staying is another example of what I always say; do not believe anything you read, unless it's official."
Massa joined Ferrari in 2006, finishing third in the championship behind Alonso and then team-mate Michael Schumacher.
The 31-year-old thought he had secured the title in 2008 when he won the Brazilian Grand Prix, only for Lewis Hamilton to gain a position on the final corner to take the championship by a single point.
The Brazilian lies ninth in the drivers' championship on 81 points but is out of contention for the title and is now focused on supporting Alonso's bid - the Spaniard is currently second to Vettel.