Veteran striker David Villa helped to fire Spain to a comfortable 3-0 win over Australia on Monday to ensure that the deposed champions left Brazil on a winning note after a miserable World Cup.
Both teams were already out of the tournament after defeats to the Dutch and Chile in group B but Villa and Spanish midfielder Andres Iniesta, who won his 100th cap, at least had something to celebrate.
Spain's record scorer, Villa put Spain 1-0 ahead with his 59th goal in 97 internationals. He flicked home in the 36th minute with a clever backheel after a fine pass from Iniesta had sent defender Juanfran clear.
Fellow striker Fernando Torres finished neatly in the 69th minute when he found space in the penalty box. Substitute Juan Mata rolled a third goal between the legs of goalkeeper Mat Ryan in the 82nd minute as Australia ran out of steam.
"In my opinion we played with dignity, we fought, we worked well apart from the first 15 minutes of the first half," Spanish coach Vicente Del Bosque said.
"The rest of the game we controlled well."
The goals silenced Brazilians fans in the crowd in Curitiba who had jeered Spain and wanted to see Australia cause them more pain.
The damage had been done for the Spain when they lost 5-1 to the Dutch and 2-0 to Chile in their first two games, ending the reign of a team who has dominated European and world soccer since 2008.
"This time it was our turn to lose and I think we go out with our heads held high," Del Bosque added, saying he will make a decision on his future once he gets home.
Del Bosque made seven changes to his starting line-up to ensure as many as his squad as possible saw some action in Brazil.
Villa, who is heading for the MLS next year via a stint at Melbourne City, got the chance to make what was probably a farewell appearance.
"If it were up to me, I would play all my life for Spain. It's more likely it will end here but we'll see," man of the match Villa told a news conference.
For Australia, the defeat was chastening after they had run the Dutch close in a 3-2 defeat last week. They leave the World Cup with no points, their worst showing at the tournament.
Australia coach Ange Postecoglou said his team had faded after performing well in the first 10 to 15 minutes.
"We lost our discipline and our decision making wasn't great. We gave the ball away far too cheaply which we haven't been doing in this tournament," he said.
Spanish goalkeeper Pepe Reina, who replaced captain Iker Casillas, had a quiet afternoon, with Australia missing suspended leading scorer Tim Cahill up front.
"Ultimately we've come here and lost all three games so we haven't got the results we wanted," said Postecoglou.