The visitors went ahead through a Rory Delap goal, but Chelsea pulled a goal back through Juliano Belletti before Lampard smashed home a vicious left-footer with seconds remaining.
Quite how Stoke lost this game is unclear as they repelled chance after chance from the home side.
City tested Chelsea's depleted rearguard in the opening two minutes with a Delap long throw and a corner. Both times the home side survived but only just.
Chelsea lost John Terry to a warm-up back injury to be replaced by Alex, with Lampard marking his 400th game for Chelsea by taking the captain's armband.
The Blues' first effort on the visitors' goal came from a weak Michael Ballack free-kick on ten minutes, which easily held by Thomas Sorensen.
Salomon Kalou missed a sitter from a deep Lampard free-kick on 24 minutes, volleying over the Stoke bar from six yards out.
Kalou then dived in the box two minutes later from a Ryan Shawcross non-tackle. Luckily for Stoke the referee Peter Walton was not fooled.
Sorensen was forced into two smart saves when first Nicolas Anelka's snap shot was parried away and then on 35 minutes Lampard's rasper was well held.
Again Sorensen was on hand, five minutes from the break, snatching a far-post header from Anelka from off the goal-line. He then produced a minute two brilliant saves, first from an Ashley Cole drive to tip the ball over his crossbar and then to kick away a Lampard daisy-cutter.
Ballack echoed Kalou's horrendous miss six minutes into the second half when the German screwed wide a free header from six yards out.
James Beattie almost embarrassed Chelsea by launching an audacious 25-yard half-volley after skimming past Cole. But the ball dipped just too late and hit the top netting of Petr Cech's goal.
But then Stoke scored on 59 minutes when Beattie fed the ball to Delap and the midfielder out ran Alex and chipped the ball over Cech's prostrate body from six yards out.
Scolari then replaced Florent Malouda with Franco di Santo.
Chelsea upped the pace and Lampard was unlucky on 66 minutes when a fine left-footer flashed wide of Sorensen's far post.
But with two minutes remaining Chelsea struck with substitute Belletti nodding home at the far post from an excellent di Santo header.
Then up popped Lampard to send the home side into delirium and Stoke into the pits of despair.