An 87th-minute penalty from Ryad Boudebouz earned Bastia a 3-2 win over Guingamp.
Frederic Hantz's Bastia side twice trailed to goals from Rachid Alioui, but recovered on each occasion.
Adama Ba got their first leveller and Sebastien Squillaci the second on a night when all five goals game in the second half.
Bastia only had themselves to blame for doing it the hard way, having failed to take a host of first-half chances.
Araujo Ilan squandered the first when clean through, before he volleyed straight at Guy Rolland Ndy Assembe when well set.
Wahbi Khazri was next up, cracking in a free-kick that was scrambled away as it threatened to go in, before Guingamp eventually woke up and closed the half with a Mustapha Yatabare volley that was blocked.
Their improvement continued into the second half and Alioui opened the scoring in the 51st minute as he finished off a counter attack with a cute lob.
Bastia were level inside two minutes, though, as Djibril Cisse flicked the ball to Ba and he did the rest.
Back came Guingamp and a third goal in four minutes put them ahead again, with Alioui scoring from close range after a cross was not cleared.
It looked as though that would be that but, with nine minutes left, a corner from Boudebouz was allowed to get to the back post and Squillaci nodded it in.
There was still time for more too as, with three minutes left, Younousse Sankhare brought down Boudebouz in the box and he got up to put the penalty away.