Striker Matthias Verschave scored the winner on 104 minutes with a little help from Sochaux goalkeeper Teddy Richert, who failed to catch his seemingly harmless deflected shot.
Third division Nimes, who had knocked out three Ligue 1 clubs on their way to the quarter-finals, opened the scoring on 23 minutes, midfielder Ulrick Chavas finding the net after collecting a headed pass from fellow midfielder Stephane Beyrac.
Two blunders in quick succession from Nimes goalkeeper Cedric Duchesne then led to as many goals from Togolese striker Mohamed Kader, who headed home in the 27th minute and tapped in from close range in the 39th.
Coupe de France
Auxerre sneak into semis
20/04/2005 AT 21:56
The visitors thought they were home and dry when Brazilian striker Ilan put them 3-1 up with a low drive from inside the box on 57 minutes.
Nimes kept fighting, however, reducing the arrears courtesy of striker Eloge Enza Yamissi on 72 minutes before forcing extra time five minutes later with a header from a corner by substitute Moise Kande.
Barca to sacrifice Griezmann to afford Messi contract - Paper Round
'I haven't seen my family for a year' Arteta on post-season plans