Ibrahimovic leaves it late for Sweden
The visitors took the lead after eight minutes through defender Olof Mellberg, who grabbed his fifth international goal when he headed in a corner from Kim Kallstrom.
Hungary came close early in the second half as Balazs Dzsudzsak shot over from 10 metres.
Sweden went even closer when Kallstrom curled the ball on to the crossbar with keeper Gabor Babos beaten.
The home team equalised in the 79th minute when Dzsudzsak was brought down by Mikael Nilsson and Szabolcs Huszti converted the penalty.
Sweden, though, had the last laugh in injury time. Ibrahimovic's first shot was saved by Babos but the Barcelona striker rolled the rebound into an open goal.
The Swedes are third in the table with 12 points from seven matches, five behind leaders Denmark. Hungary are second on 13 points.