The result left Chelsea second on 13 points from six games, two behind group winners Juventus who leapt into pole position thanks to a 1-0 home win over Sweden's Malmo.
Both sides had already booked their last-16 berths while third-placed Zenit will go into the second-tier Europa League after the winter break.
Chelsea made a perfect start as Timo Werner fired them ahead in the second minute with a tap-in after a Ross Barkley corner was nodded into his path.
Mason Mount squandered a sitter to double the lead after Zenit twice came close to an equaliser and the England midfielder's miss turned out to be costly as the home side turned the game round with two quickfire goals.
Brazilian forward Claudinho levelled in the 38th with a glancing header into the far corner after his compatriot Douglas Santos swung in a cross past a static visiting defence.
Rattled by the equaliser, Chelsea fell behind three minutes later when Iranian striker Sardar Azmoun beat the offside trap from Malcom's fine through ball and slotted home after rounding goalkeeper Kepa Arrizabalaga.
Romelu Lukaku hit back in the 62nd minute as he stroked the ball into an empty net after a flowing move and Chelsea seemed to have forced the final twist after Werner struck again in the 85th thanks to more crisp-one touch passing.
The move left Zenit's defence bedazzled with Christian Pulisic delivering the final pass to Werner, who fired in a snap shot from 10 metres after side-stepping his marker.
The Premier League side were undone, however, by a spectacular equaliser at the death as they failed to clear a cross and Magomed Ozdoev unleashed an unstoppable volley into the top corner from the edge of the penalty area