Samir Nasri came to the rescue to send France through to the Euro 2012 finals after Bosnia-Herzegovina had threatened to pull off an upset at the Stade de France.
Edin Dzeko's stunning 40th-minute strike looked set to be enough to send Bosnia to the finals before his Manchester City team-mate Nasri was tripped in the box 12 minutes from time and got up to coolly convert the spot-kick.
Nasri's goal guaranteed France their place in Poland and Ukraine next summer while disappointed Bosnia must settle for a place in the play-offs. Also in Group D, Romania were held to a 1-1 draw in Albania.
Denmark got the win they required over Group H rivals Portugal in Copenhagen, sending the Danes through to the finals with a 2-1 win and leaving their opponents to settle for the play-offs.
The Portuguese started the night on top of the pool on goal difference but a 13th-minute goal from Michael Krohn-Dehli put the initiative in the hands of the classy home side.
Nicklas Bendtner added a second in the 63rd minute to send the Danes into the finals, despite Cristiano Ronaldo's 90th-minute consolation. Also in Group H, Norway beat Cyprus 3-1.
Greece edged through from a fiery Group F but the 2004 winners left it late before coming from behind to beat Georgia 2-1 in Tbilisi and qualify at the expense of runners-up Croatia.
David Targamadze put the Georgians ahead in the 18th minute and Greece had to wait until the 78th minute for Georgios Fotakis to strike the equaliser. Angelos Charisteas made sure five minutes from time.
Greece's win left Croatia to settle for a play-off place despite goals from Eduardo and Mario Mandzukic giving them a 2-0 win over Latvia in Rijeka. Also in the group, Israel won 2-0 in Malta.
Sweden shattered already-qualified Holland's hopes of finishing Group E with a 100% record, with the Swedes' 3-2 win ensuring they also qualified directly as the best runners-up.
Kim Kallstrom opened the scoring for the Swedes and although Klaas Jan Huntelaar and Dirk Kuyt replied for the Dutch, Sebastian Larsson and Ola Toivonen won it in the second half. Hungary drew 0-0 with Finland and Moldova beat San Marino 4-0.
Turkey made hard work of overhauling Belgium to take the play-off spot in Group A, scraping a 1-0 win over Azerbaijan in Istanbul thanks to Burak Yilmaz's 60th-minute strike.
Belgium started the night in the play-off berth but were always up against it in Germany, who wrapped up a 100% qualifying campaign with a 3-1 win in Dusseldorf.
Two goals in the space of three first-half minutes from Mesut Ozil and Andre Schurrle put the hosts on course for yet another victory, with Mario Gomez adding a third just after the interval.
Marouane Fellaini grabbed a consolation in the 86th minute but it was not enough for Belgium.
Earlier, Austria were held 0-0 in Kazakhstan.
Spain also finished with a 100% record in Group I, two David Silva goals helping them to a 3-1 win over Scotland, while the Czech Republic took second with a brace each for Jan Rezek and Michal Kadlec in a 4-1 win in Lithuania.
With both qualifying and play-off places already decided in Group G, Switzerland took third with a 2-0 win over Montenegro while Wales finished on a high with Gareth Bale giving them a 1-0 win in Bulgaria.