After losing their previous matches in Group B to the Netherlands and Chile, both teams took to Arena da Baixada in the southern Brazilian city of Curitiba knowing they could not advance to the second round.
David Villa, on his 97th and final appearance put Spain ahead in the 36th minute with his record 59th goal, guiding Juanfran Torres' pass into the net with the inside of his right foot. Juanfran had been found by a typically incisive pass by Andres Iniesta.
Iniesta was at the heart of the second goal too. Fernando Torres doubled Spain's lead in the 69th as he steered the ball past Australia goalkeeper Maty Ryan following aq pass from Andres Iniesta.
Juan Mata added a third in the 82nd from close range after he was found in space by Cesc Fabregas. And David Silva nearly went close to making it four in the 89th but his shot from just outside the Australia penalty area went just wide.
Spain coach Vicente del Bosque, who reshuffled his lineup for the match, said: "There are still players who can help the team a lot and while we have to be aware of the younger players coming through, we shouldn't write off anybody."
Though nothing rested on the game, Spain showed some of the football that has seen it dominate the game over the past six years — winning Euro 2008, its first World Cup in South Africa in 2010 and then Euro 2012.
Australia started the match brightly but it wasn't long before Spain took control and started dominating possession.
As a result of its victory, Spain avoided the worst World Cup title defence in history. That label remains with the France team of 2002, which only secured one point in its goal-less campaign in the tournament co-hosted by South Korea and Japan.