The British champion was expected to end his career at Mercedes, the team where he won six of his seven world titles.
Despite this, they have struggled during the ground effect era, and the failure to provide Hamilton with a race win may be one of the reasons for him leaving.
Elkann looks forward to welcoming Lewis to Ferrari
"I have always said over the years how much Lewis is a great driver, how much he has done for F1,” Elkann told Sky.
“He will join Ferrari and this is a sign of how much he believes he can do great things with us.”