Fernando Torres put this week's controversies behind him as he fired Spain ahead in the 15th minute but Zlatan Ibrahimovic levelled things up in the 34th minute with a goal that looked to have earned Sweden a share of the points.
That was until Villa, who scored a hat-trick in Spain's 4-1 win over Russia on Tuesday, struck right at the death to put his side on the brink of the quarter-finals.
Meanwhile, Russia beat Greece 1-0 in Salzburg to dump the defending Cup holders out of Euro 2008.
The Greeks needed at least a draw to stay in contention in Group D, but Konstantin Zyryanov's 33rd-minute goal, combined with Spain's 2-1 win over Sweden, left the surprise 2004 champions with nothing to play for in their third and final match.
Zyryanov's third international goal in 14 appearances came after Sergei Semak acrobatically sent a pass back across the net, with goalkeeper Antonis Nikopolidis chasing the loose ball.
Russia will qualify for the quarter-finals if they defeat Sweden in the final qualifying Group D match.
On June 15, Portugal, which have already clinched a last-eight spot, will take on ousted co-hosts Switzerland, while Turkey will play a crucial match against the Czech Republic. If Turkey draw the Czech Republic, they will enter the penalty shoot-outs under new FIFA rules to select another Group A team for the knock-out stage.
Add new comment