Surprising Saudi Arabia also advanced after routing Guatemala 6-0. Nigeria did the same by beating Croatia 5-2, while Costa Rica kept alive its hopes of reaching the second round with a 3-2 victory over Australia.
Spain struggled early against Ecuador in Manizales but picked up the pace after Canales came off the bench in the 56th minute, playing for the first time after a lingering muscle injury.
Canales scored from close range in the 67th and set up Alvaro Vazquez's goal with a nice through ball in the 85th. Vazquez had also came in as a second-half substitute.
''I'm very happy because it's not easy to come back from an injury,'' said Canales, who had been nursing a muscle ailment on his left leg. ''We played with a lot of heart in this match and now we are already through to the second round.''
The victory gave Spain six points from two matches in Group C, three more than Costa Rica and five more than Australia and Ecuador.
Having already guaranteed its spot in the knockout stages, Spain has the option of resting its top players when it plays its last group game against Australia on Saturday, but coach Julen Lopetegui says the team will not relax.
''I don't think we will change the way we play,'' he said. ''We always come out to win and that objective hasn't changed.''
Ecuador, which will play its final group match against Costa Rica, was a man down from the 65th after midfielder Christian Ona was ejected for a second yellow card.
''We played a great match but we didn't have enough luck to score even though we created many chances,'' Ecuador coach Sixto Vizuete said. ''Without disrespecting Costa Rica, we still haven't lost anything. If we play like we played against Spain, we can think about earning four points and advancing.''
Costa Rica will be boosted by its victory against Australia, though, thanks to defender John Ruiz's winner in the 72nd-minute in Manizales.
Striker Joel Campbell opened the scoring for Costa Rica in the 22nd. Tommy Oar equalized for Australia in the 26th, but Campbell netted again a minute later. Australia evened the match with an own goal by defender Franciso Calvo in the 64th, but Ruiz's header off a cross by Campbell gave Costa Rica the victory.
''It was a very difficult match, very intense,'' Costa Rica coach Ronald Gonzalez said.
Australia's Dutch coach Jan Versleijen said his team deserved better luck.
''We let this one get away,'' Versleijen said. ''We will have to get a good result against Spain, there is no alternative. It's going to be hard, no doubt. Spain is the best team in the group, but we are not giving up yet.''
In Armenia, substitute striker Uche Nwofor scored two second-half goals to give Nigeria a 5-2 victory over Croatia and a berth in the second round.
Striker Olarenwaju Kayode scored in 25th minute and defender Terna Suswan in the 30th to give Nigeria an early advantage at the Centenario stadium. Ivan Lendric put Croatia on the board in the 42nd before Nigeria sealed the victory with Ahmed Musa in the 62nd and Nwofor in the 69th and 73rd minutes.
Nigeria has a perfect six points from two games in Group D, along with Saudi Arabia, which got goals from six different players in its rout of Guatemala, which lost its opening game 5-0 to Nigeria, was eliminated from contention for the second round.
''We were nervous after the first goal and missed too many passes,'' Guatemala's Paraguayan coach Ever Almeida said. ''It was an honor to come here. The players did everything possible, but football is more than just heart.''
Tales Azzoni can be reached at http://twitter.com/tazzoni