The Ligue 2 leaders, relegated from Ligue 1 in 2011, powered through after recovering from a disastrous start thanks to Ibrahima Toure's double.
Valenciennes looked to be cruising to a straightforward win after Gael Danic and an Andreas Wolf own goal put them 2-0 up after 32 minutes.
But Senegalese striker Ibrahima Toure, who has scored nine goals in eight Ligue 2 games this season, pulled one back in the 35th minute with a close-range header.
Yannick Ferraira Carrasco equalised with a penalty on the stroke of halftime.
Lucas Ocampos added a third after being set up by Toure 14 minutes into the first half of extra time before Toure sealed the win in the last minute.
Nice, Toulouse, Troyes and second-tier Arles-Avignon also moved into the last 16 of the Coupe de la Ligue after victories.
St Etienne defated Lorient on penalties after a 1-1 draw, while Sochaux beat Evian Thonon Gaillard 3-2 after extra-time.
With seven matches being played in addition to three on Tuesday, Nice won 4-2 at Stade Brestois, Arles-Avignon claimed a last-gasp 2-1 win at home to Ligue 1 Ajaccio, Troyes triumphed 2-1 at neighbours Reims and Toulouse sealed a narrow 1-0 victory at Caen.
Nice’s win against Brest came in the afternoon, the 4-2 scoreline exactly the same as that which saw the Cote d’Azur side triumph in Ligue 1 a week and a half ago. Argentine striker Dario Cvitanich scored twice, his first goals for Nice, while Brest winger Larsen Toure was sent off with 18 minutes left.
Toulouse toiled in victory at Ligue 2 Caen, with on-loan Benfica striker Yannick Djalo netting with six minutes remaining.
Troyes lie bottom in Ligue 1 but boosted their poor season so far with a win at fellow Champagne-based promoted side Reims. Nicholas Fauvergue put the hosts ahead but goals from Granddi Ngoyi and Mohamed Yattara gave the visitors victory.
Arles-Avignon sprung the biggest surprise of the night as Haminu Draman scored in extra-time to seal a 2-1 win over Corsican side Ajaccio. Maurice Dale had put the hosts ahead just after the hour mark, with Ricardo Faty levelling late on.
Three other teams qualified for the last 16 on Tuesday – Rennes, Bastia and Auxerre – with Montpellier, Paris SG, Lille, Lyon, Bordeaux and Marseille all handed byes to the last 16 due to their participation in European competition.