Lyon dominated the tie following Jimmy Briand's ninth-minute opener but Pierrick Valdivia levelled for the visitors from the penalty spot in the third minute of injury time after substitute Mehdi Zeffane had fouled Adamo Coulibaly.
Full back Jean-Philippe Gbamin then headed northerners Lens in front five minutes into extra-time and Lyon missed chances to equalise.
Former French champions Lens, owned by Azeri billionaire Hafiz Mammadov, are currently third in the Ligue 2 table, a spot that would earn them promotion at the end of the season.
They will visit Monaco, considered the Cup favourites after Ligue 1 leaders Paris St Germain were eliminated in the previous round, in the quarter-finals next month.
Only four Ligue 1 sides have qualified for the quarter-finals with Guingamp visiting fourth-tier side Cannes and Stade Rennais welcoming Lille. The last tie will see fourth-division club Moulins take on Ligue 2 outfit Angers.