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 the 2010 World Cup and the Euros in 2008 and 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.
“The best goalkeeper in the history of Real Madrid and Spanish football joined us at the age of 9. He was formed here and defended our shirt for 25 years, becoming one of our most emblematic captains of all time,” the club said in a statement.
“Today one of the most important footballers in our 118 years of history calls it a day as a professional player, a player we love and admire, a goalkeeper who has made the Real Madrid legacy bigger with his work and exemplary behaviour both on and off the pitch,” they added.
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.
- AFP