Belgium finished as Group E runners-up and will face Hungary in Toulouse on Sunday, as they defeated Sweden in Nice. Sweden exited the competition with one point from three games in which Ibrahimovic failed to score.
The Republic of Ireland qualified in third thanks to a 1-0 win over Italy. It seemed Belgium might start matching the expectations around their talented squad with a 3-0 win over the Republic on Saturday.
Roma midfielder Nainggolan's 84th-minute swerving right-footed finish, angled into the bottom-left corner via a slight deflection, was a moment of high quality. However, a starting 11 that comprised 6 Premier League players and featured just one change from the win over the Republic lacked decisiveness in the attacking third of the pitch.
Kevin de Bruyne was the most industrious option for Marc Wilmots' team, providing the cross for Thomas Meunier to flash a header wide and putting through Romelu Lukaku for a one-on-one chance which the Everton striker squandered - but they still have plenty of room for improvement.
This was probably Sweden's most effective performance of the tournament - they mustered four shots on target, having not registered a single one in the previous two games.
They were unlucky not to lead minutes before Nainggolan's winner, when Andreas Granqvist's header was cleared off the line by De Bruyne.
But Sweden finished bottom of the group with one point, an unfitting way to end the international career of 116-time capped Ibrahimovic, the country's record goal scorer.
The 34-year-old, a reported target for Manchester United after he left Paris St-Germain this summer, announced this week he would retire from Sweden duty.
He failed to add to his 62 international goals and did not register a shot on target until this final group game.
His own frustrations were echoed by Sweden, who did not see one of their own players find the net in the tournament - their only goal was scored by the Republic's Ciaran Clark in the opening 1-1 draw.