David Villa scored his record 59th goal in his final match for Spain as the defending champion led Australia 1-0 at halftime at the World Cup on Monday.
Villa, making his 97th appearance, intelligently guided Juanfran Torres' cross from the goal line into the net with the inside of his right foot in the 36th minute.
Neither team can advance to the second round after losing both their previous matches in Group B.
Spain dominated the match after Australia's better start, with Andres Iniesta crossing for Villa to volley wide of the left post after 21 minutes.
Fernando Torres then failed to convert Villa's cross from inside the box in the 34th.