Giancarlo Fisichella will be the second Ferrari driver from the Italian Grand Prix, after he was released from his contract by his Force India team on Thursday.
The announcement was made by Force India, which confirmed that Fisichella would switch teams from the Italian Grand Prix.
The team said that discussions with Ferrari began in the last 24 hours, once it became clear that Massa was out for the season.
Force India owner Dr Vijay Mallya said: "Giancarlo and his management team approached me yesterday with the proposal from Ferrari.
"For any Italian driver, a Ferrari race seat is a long-held dream and for Giancarlo it was no exception. No one should stand in the way of this.
"Furthermore the agreement will secure Giancarlo's long-term future with Ferrari and it would be incorrect to jeopardise this, particularly when Giancarlo has made such a vital contribution to Force India."
Force India is understood to have outstanding debts with Ferrari left over from its customer engine supply deal that ended last year - but Mallya said that commercial factors did not have a role in the outcome.