PARIS -- Zlatan Ibrahimovic scored a last-gasp penalty as defending champion Paris Saint-Germain rallied to beat Toulouse 2-1 and reach the last 16 of the French Cup on Tuesday.

Ibrahimovic scored a late header when PSG won 1-0 at Toulouse in the league last weekend, and his winner this time came in the 89th minute after Toulouse defender Uros Spajic clumsily tripped left back Layvin Kurzawa just inside the penalty area.

Ibrahimovic sent goalkeeper Mauro Goicoechea the wrong way from the spot to prompt relieved celebrations at Parc des Princes.

More from FoxSports

Toulouse outplayed PSG in the first half, and took the lead when defender Francois Moubandje swapped passes with midfielder Adrien Regattin and slotted past goalkeeper Salvatore Sirigu.

Center half David Luiz headed PSG level after halftime.

Despite fielding a weakened side and keeping top-scorer Wissam Ben Yedder on the bench, Toulouse -- which is 19th in the French league -- took the game to PSG.

"It was a difficult game. They played really well and we didn't have much intensity," Luiz said. "We were too slow in attack and defense. The second half was better."

Goicoechea, Toulouse's third-choice goalie, saved Luiz's curling shot, and pushed away Kurzawa's attempt just before the interval as PSG finally clicked.

Moubandje almost made it 2-0 just after the break, but Sirigu palmed away his rasping drive from the edge of the penalty area.

PSG equalized following a poor passage of play from Toulouse. Several players failed to play the ball out from midfield and it was eventually played back to Spajic, whose fluffed clearance went behind for a corner.

Luiz met Ezequiel Lavezzi's corner with a powerful header into the top right corner.

Ibrahimovic thought he scored with his first touch after coming on in the 65th when he followed up Luiz's shot. But the linesman correctly flagged that Luiz was offside on his initial shot.

"Once again we're frustrated, because even though we cause them trouble they still manage to win," Regattin said. "We've got one chance left to beat them."

The sides meet again next week in Paris, this time in the League Cup semifinals.

In other matches, striker Khalid Boutaib scored a hat trick to take his tally to five goals in the past three matches as Corsican side Gazelec Ajaccio beat Guingamp 3-0 at home.

Bordeaux won 2-1 at Angers, and striker Raphael Caceres scored in the fifth minute of injury time as second-division Sochaux won 2-1 at Bastia, and there was another upset as Rennes lost 3-1 at home to second division Bourg-Peronnas.

Marseille's home game against Montpellier is the pick of Wednesday's French Cup games.