Istres saw off top-flight Valenciennes in a penalty shoot-out to book their place in the next round of the Coupe de France.
A topsy-turvy encounter saw the second tier outfit veer dangerously close to bowing out before then throwing away a two-goal lead to take the tie to spot kicks.
Mathieu Dossevi appeared to have won the game for Valenciennes with his 74th minute opener.
There was, however, to be a late twist as Sid Ali Yahia-Cherif pounced in stoppage-time to restore parity.
Both sides went on to net twice in extra-time, with a brace from Nassim Akrour (101 and 103) putting Istres in complete control.
They were unable to hang onto their lead, though, and saw Vincent Aboubakar (111) haul Valenciennes back into the game before Rudy Mater converted from the spot six minutes from the end.
Istres could have been forgiven for thinking their opportunity had passed, but they held their nerve from 12 yards to prevail 4-3 in a shoot-out.
Istres will face minnows Raon L'Etape in the last 32.