Ivory Coast striker Wilfried Bony had opened the scoring for Swansea before Gabriel Agbonlahor levelled.
Inspired by Shelvey's moment of magic, Swansea dominated the second half and were rewarded with Pablo Hernandez's strike before Bony added to his tally with a stoppage-time penalty.
Barring a remarkable mathematical swing against them over the final two weeks, Swansea's second successive win has effectively secured their top flight status.
Villa, meanwhile, are now without a win in six matches and only four points above the relegation zone with a tough run-in.
Bony opened the scoring in the 10th minute when he latched on to a through-ball from Shelvey that pierced Villa's high defensive line.
Centre-back Nathan Baker appealed for offside, but the flag stayed down and Bony side-footed past Guzan with ease to bag his 14th league goal of the season.
Villa equalized in the 22nd minute thanks to some slick football down the right. Karim El Ahmadi slipped the ball down the flank to Marc Albrighton, whose curling cross was converted by Agbonlahor from close range.
The goal ended a Premier League drought of three hours and 42 minutes for Lambert's team. But Shelvey's wonder-strike put Garry Monk's side back in front three minutes later.
After chesting down Villa captain Ron Vlaar's clearance, he hit a missile of a volley from 45 yards that cleared the stunned Guzan and curled into the top corner.
Jonathan De Guzman should have extended Swansea's lead when he shanked the ball wide from a Wayne Routledge cross on the hour.
Monk's men continued to probe and press and were rewarded for their dominance when Hernandez made it 3-1. The Spaniard was free at the back post when Shelvey crossed, cut in field and scored via the head of Ryan Bertrand, who was back defending the goal-line.
Villa's misery was compounded in stoppage-time when Baker pushed substitute Marvin Emnes in the back and conceded a penalty which Bony slammed home.
Swansea City 4-1 Aston Villa Highlights