Epinal, 19th in the 20-club third division, scored in the 75th minute to force their visitors to extra-time at 3-3 after Lyon had recovered from two early goals down to take the lead midway through the second half.
Lyon, who hit the woodwork twice in extra-time, were near full strength with goalscorers Bafetimbi Gomis and Lisandro Lopez paired up front.
The semi-professional side Epinal eventually snatched a 4-2 win in the penalties shootout after Lyon's Gueida Fofana and Bakary Kone missed their attempts.
"It's magical and now we hope to reach the last 16 and make history," Epinal goalkeeper Olivier Robin said.
Apart from Lyon, who are second in the Ligue 1 standings level on points with leaders Paris St Germain, two other top flight sides were dumped out of the French Cup on Sunday.
Third-tier CA Bastia scored twice in three minutes just before half-time to beat neighbours Bastia 2-0 while second division Lens eliminated Rennes.
Rennes' Julien Feret cancelled Jerome Le Moigne for Lens with nine minutes to go, only to see Kevin Theophile-Catherine's own goal one minute later which handed the home team a deserved 2-1 victory.
Lowly Ligue 1 clubs Ajaccio and Reims were eliminated by lower division clubs on Saturday.
In Marseille, Andre-Pierre Gignac struck twice to rescue the record ten-times winners, earning them a laboured 2-1 victory after extra-time over second division 2009 winners Guingamp.
Queens Park Rangers manager Harry Redknapp was in the stands to watch France forward Loic Remy, according to media reports.
Elsewhere, right-back Mariano's stoppage-time goal earned Bordeaux a 3-2 victory in a thriller at ten-man second-tier club Chateauroux.
St Etienne won at Ligue 2's Caen by the same score, while French champions Montpellier defeated third division side Bourg Peronnas 2-1.
Later, Paris St Germain went all out to hold off an energetic Arras to advance 4-3.
PSG took a two-goal lead within two minutes thanks to Blaise Matuidi and Ezequiel Lavezzi. But the fifth-tier side kept clawing back until the end, as Sebastien Bernard grabbed a third goal for Arras nine minutes from time soon after Lavezzi scored his second.


