Monaco came back from the brink to beat Sochaux 4-3 at home and book their place in the French Cup semi-finals on Wednesday.
Striker Moussa Maazou netted the winner after Colombian forward Juan Pablo Pino had sent the tie into extra time with a last-gasp equaliser.
Monaco joined Paris St Germain and amateurs Quevilly in the last four, with RC Lens and St Etienne playing for the remaining spot later on Wednesday.
Sochaux opened the scoring in the 29th minute when Ryad Boudebouz took advantage of a bad clearance by Stephane Ruffier to lob the Monaco keeper.
But Monaco struck back five minutes later, with defender Sebastien Puygrenier heading home from a Nene free kick, and went ahead in the 38th when Lukman Haruna found the back of the net with a splendid volley from the edge of the box.
The hosts then sat back and were caught off guard three minutes into the second half.
Stephane Dalmat played a fine one-two with Marvin Martin before coolly slotting home to make it 2-2. Dalmat then set up Nigerian Ideye Brown with a through ball for Sochaux's third in the 71st.
The visitors wasted a great chance four minutes into added time and on the counter attack, Pino sent the game into extra time with a shot that was slightly deflected by Sochaux's Damien Perquis.
Still recovering from the shock, Sochaux conceded a fourth in the 95th when Maazou poked the ball home after Teddy Richert failed to block Pino's attempt.
The draw for the semi-finals will be made on Sunday.