Zlatan Ibrahimovic grabbed a last-gasp winner as Sweden stayed in the hunt for a top-two finish in European Zone Group 1.

The Barcelona striker enjoyed a huge slice of luck when Hungary goalkeeper Gabor Babos saved his shot but could only watch in horror as the ball bounced over the line off Ibrahimovic's chest. Sweden had looked as though they would have to settle for a draw in Budapest after a penalty from Szabolcs Huszti cancelled out Olof Mellberg's early opener

That would have left them on 10 points after seven matches, four behind Hungary, who would have had 14, but Ibrahimovic's goal means the Swedes are just a point adrift of their hosts tonight, who themselves are four points behind unbeaten group leaders Denmark. Portugal, the favourites for the group, are down in fourth place.

Mellberg put Sweden in front after eight minutes with a header from Kim Kallstrom's corner, and the away side had most of the play in the rest of the first half. The Swedes threatened to score early in the second half, too, but Ibrahimovic shot just wide of the right post in the 49th minute.

Johan Elmander then saw his shot deflect over the bar as Sweden pressed for a second goal. Hungary went close to an equaliser in the 55th minute, when Balazs Dzsudzsak shot wide.

However, Sweden remained the most threatening side and Kallstrom hit the bar a minute later with a shot from outside the penalty area. Samuel Holmen was the next Swedish player with a chance to strike but he could not apply the right sort of finish to a neat pass from Mikael Nilsson.

Hungary drew level with Huszti's penalty in the 78th minute after Dzsudzsak was brought down by Holmen. However, Sweden had the final say, four minutes into stoppage time, when Ibrahimovic raced through on goal and bizarrely found the net.