Casillas pulled off a stunning reflex stop to keep out an Ivan Rakitic header in the 59th minute at the PGE Arena in Gdansk before substitute Jesus Navas snatched an 88th-minute winner for the world and European champions.
Croatia battled impressively to keep the Spaniards at bay and had they scored and held on to their lead they would have advanced to the quarter-finals as group winners and Spain would have been out.
Casillas has earned the nickname "Saint Iker" for his match-saving performances for his country and will always be remembered for denying Arjen Robben in the 2010 World Cup final.
"We knew they weren't going to just sit back and we were expecting them to create the odd chance," Spain coach Vicente del Bosque told a news conference.
"They had an excellent opportunity but that is why Iker is there and he dealt with it very well," he added.
If Del Bosque was his usual gruff self, his Croatian counterpart Slaven Bilic was far more effusive in his praise of Casillas at his news conference.
"What can we say about him? He is probably one of the best players of the past 10 years," said the 43-year-old, who is stepping down to take over at Lokomotiv Moscow after the tournament.
"He is just the leader for the team and he was a hero for them tonight," he added.
"He always knows how to react and he is so calm. Rakitic had a great clear chance and did everything well but it's not easy when you are facing Casillas."
Spain topped the group on seven points ahead of Italy on five, Croatia on four and Ireland on zero.
Del Bosque's side will play Group D runners-up France, England or Ukraine.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.