Legace recorded his 16th career shutout and the Blues won their third straight game. St. Louis is now 21-5-2 at San Jose.
Guerin's game winner came with just 1:24 left in the second when he wrapped around the goal and flipped the puck past Sharks goalie Evgeni Nabokov.
Since St. Louis fired coach Mike Kitchen on Dec. 11, and hired Andy Murray, the team has come alive, going 12-4-4 and moving back into the playoff hunt.
Guerin's 20th goal of the season was the 10th time in the last 12 home game that the Sharks had surrendered the first goal of the game.