The Championship leaders were in danger of falling to their first defeat in 10 matches with five minutes remaining, trailing 2-1 against a Millwall side who have not won at home since Boxing Day.
But Paul Robinson, whose volley put Millwall ahead after Jose Fonte's own goal had cancelled out Lambert's opener, fouled the striker in the area for his first spot-kick and three minutes later Alan Dunne was adjudged to have handled and Lambert helped himself to another treble.
There was no sign of the drama to come when Lambert fired Southampton into an early lead.
The in-form striker had already thumped the crossbar with a vicious drive from 25 yards which Lions debutant goalkeeper Maik Taylor may have got the faintest of touches on.
And Saints went deservedly ahead after a quarter of an hour when Danny Fox sent Morgan Schneiderlin clear and he rolled the ball across goal for Lambert to fire in off the underside of the bar.
But the Lions, whose wretched home form means they are still looking over their shoulder at the relegation battle, grabbed a shock leveller against the run of play in the 21st minute.
Andy Keogh twisted and turned in the area and when his left-footed shot hit a post, the ball rebounded off the luckless Fonte and into his own net.
It got worse for Saints six minutes later when they failed to clear James Henry's corner and when the ball came back across goal skipper Robinson was on hand to rifle it into the roof of the net for his first goal since the opening day of last season.
Robinson nearly grabbed his second with a header from another Henry corner, but Southampton keeper Kelvin Davis managed to block.
After the break Robinson was back in his regular position at centre-half, blocking a goalbound shot from substitute Steve de Ridder.
But Southampton's defending from corners was proving their undoing and they nearly conceded a third when Darius Henderson's header was cleared off line by Frazer Richardson.
Davis then surely feared he was going to be shown a red card when he handled outside the area, but the Saints keeper was saved by an offside flag which had already been raised.
And Saints were thrown a lifeline in the 85th minute when Lambert was brought down by Robinson and the striker smashed in the equaliser from the spot.
And moments later referee Fred Graham stunned the home fans when he pointed to the spot again after Dunne handled and Lambert rammed home his 28th goal of the season two minutes from time.