Casillas, 39, also won the European Championship twice with his country in a trophy-laden career which included more than 700 games for Real Madrid.
“Today is both one of the most important and most difficult days of my sporting life, the time to say goodbye has arrived,” he said on Twitter.
Casillas joined Portuguese side Porto in 2015 after a tearful departure from Madrid but suffered a heart attack in May last year.
He played 167 times for the national team, winning trophies in 2008, 2010, 2012 in a golden age for Spanish football.
He lifted five La Liga titles and the Champions League on three occasions during his time at the Santiago Bernabeu.
In June he said he was ending his bid to run for the presidency of the Spanish Football Federation (RFEF) due to the crisis caused by the coronavirus pandemic.
Download our app and read this and other great stories on the move. Available for Android and iOS.