Williams and Anze Kopitar each had two goals and an assist, and Jonathan Quick made 25 saves as the Kings became just the ninth team in NHL history to force a seventh game after losing the first three.
"We certainly didn't want to go away quiet," Kopitar said.
Stalock stopped 26 shots in his first NHL playoff start, and James Sheppard scored for the spiraling Sharks.
Just three teams in NHL history have rallied from an 0-3 deficit to win a series.
Los Angeles could join them in Game 7 in San Jose on Wednesday. The winner of the California rivals' third playoff meeting in four years will face the top-seeded Anaheim Ducks in the second round.
Williams, a two-time Stanley Cup champion known for clutch playoff goals, also scored in the first period. He reached his stick between Stalock's pads and knocked home Robyn Regehr's shot for the go-ahead score, breaking open a tense game.
Kopitar followed with two goals 1:15 apart for the Kings, who have outscored San Jose 13-4 in the last three games after San Jose dominated the first three by a combined 17-8.
Sheppard scored on a double deflection in the second period, but after utterly dominating the first two games, San Jose has scored just one goal against Quick in the last 128:24 in the series.
Sharks coach Todd McLellan changed starting goalies after Stanley Cup winner Antti Niemi was pulled from each of the last two losses. McLellan took a risk on Stalock, whose NHL experience consists of 27 regular-season games and 57 minutes of scoreless relief in this series.
Drew Doughty had two assists for Los Angeles, which lost the first three games of the series in discouraging fashion before rallying with resounding victories at home in Game 4 and at the Shark Tank in Game 5 last Saturday night. Doughty set up the Kings' first goal with a sharp pass to Williams, who has four goals in the Kings' last two home games.
San Jose got a 5-on-3 advantage for 1:38 early in the second period, but the Kings killed it off to the delirious cheers of their home fans. The Sharks finally tied it moments after a third fruitless power play when Sheppard deflected Justin Braun's slap shot out of mid-air and off Regehr.
After Williams' go-ahead score, Kopitar got loose on a 2-on-1 rush with Williams, who set him up perfectly. Kopitar added a power-play goal, and the final minutes devolved into several wild scrums after the whistle.
Just three teams have accomplished the Kings' potential feat, but the Philadelphia Flyers rallied from three games down to beat Boston in 2010 with a roster including current Kings forwards Jeff Carter and Mike Richards.
The Sharks played without key defenseman Marc-Edouard Vlasic, who left Game 5 early with an upper-body injury. The Canadian Olympic gold medalist was replaced by Matt Irwin, while streaky forward Marty Havlat also was in San Jose's lineup for the first time in the series, replacing Mike Brown.
NOTES: Los Angeles lost D Willie Mitchell to an undisclosed injury during the second period. ... Stalock's career nearly ended in the AHL in 2011 when Los Angeles forward Dwight King's skate blade severed a nerve behind his knee. The goalie missed nearly a year of action. ... Los Angeles played its NHL-high 44th playoff game in the past three years. ... The Sharks hadn't changed their starting goalie during the playoffs since 2001, when Miikka Kiprusoff took over for Evgeni Nabokov during a series. ... Vlasic had played in all 84 possible playoff games since joining the Sharks for the 2006-07 season.