The hosts were unlucky not to have taken the lead in the 20th minute when Wahbi Khazri hit the right post with a left-footed shot from an acute angle on the left.
Then just after the half-hour mark Valenciennes went ahead through a Foued Kadir goal.
However, five minutes from the half-time interval Bastia equalised when Anthony Modeste converted a penalty earned by Khazri.
However, Valenciennes came back strongly thereafter, with Kadir blasting home from outside the 18-yard box to restore parity in the 78th minute.
Two minutes later Mathieu Dossevi scored the winner for the visitors, as he was fed by Kadir to shoot home from the right side of the box.