The Roma midfielder, reportedly wanted by Chelsea, controlled a cross from Eden Hazard outside the area and powered it into the net in the 82nd minute. Belgium now take on Hungary in Toulouse on June 26th.
Sweden finished fourth in the group and will look back with regret on a flat performance in their opener against Ireland.
Facing elimination if defeated, both teams pushed forward to attack which produced a pulsating first half hour in balmy Nice.
Chances came thick and fast. Sweden almost had a dream start three minutes in when a goalmouth half-volley by Marcus Berg, in for John Giudetti as strike partner to Ibrahimovic, was batted out by Thibaut Courtois.
Playing in unfamiliar turquoise jerseys, Belgium launched regular raids with Kevin De Bruyne through the middle and Hazard, roving from wing to wing, at the heart of the danger.
Midway through the half, a backheel from Hazard let the Man City star fire a shot straight at the Isaksson.
Another surging De Bruyne run forced a yellow card for Albin Ekdal after a last-ditch trip on the Man City star, while twice in five minutes he drilled dangerous crosses across the goalmouth.
But Sweden's defence contained Romelu Lukaku, whose double against the Republic of Ireland in Belgium's previous game resurrected their Euro 2016 campaign after the opening defeat to Italy.
At the other end, Ibrahimovic had little joy, bar the occasional half-chance snapshot or attempt at a spectacular volley.
But none came to anything on an ultimately frustrating night for the Swedish legend who announced his international retirement ater Euro 2016 on Tuesday.
It was Belgium who nearly entered the break in front, when Merrier headed an inch-perfect De Bruyne cross just wide of Andreas Isaksson's post.
As the clock ran down in the second half the temperature began rising again.
Belgium had a strong penalty claim turned when a Carrasco cross was blocked, while on the hour Isaksson dived at full length to keep out a De Bruyne drive.
With fifteen minutes to go Belgium nearly made a breakthrough when a powerful Lukaku break was foiled by Isakksson who spread his body well to the shot.
A minute later, an identical run by the Everton striker, this time with a neat finish, was ruled offside.
Time was running out on Ibrahimovic when he went close with a free kick turned away by Courtois with a quarter hour to go.
Then a header was cleared off the line by Meunier.
But there was to be no salvation for Sweden, nor one more game for Ibrahimovic.
He battled to the end, almost snatching a late equaliser with a half volley on the turn, but the dying minutes were instead marked by the Belgian fans raucously chanting “Bye Bye Ibrahimovic!”