Leading 1-0, the Sharks scored two goals in the third period, the first one following a great save by Stalock.
Scottie Upshall took a shot from in front but Stalock stuck his leg out to barely block it.
The Sharks took the puck quickly back the other way and Tyler Kennedy took a shot from the right side of the crease. Tim Thomas stretched to block it, but Nieto was there to sweep in the rebound at 4:44.
"I ended up getting there and sometimes that happens where you make a big save on one end and right away on the other you get a chance like that," Stalock said. "We capitalized and that was a big turning point."
Upshall thought he had a great chance at a goal.
"I pretty much had the whole net to shoot at and he got his leg on it," Upshall said. "It could have been a game-tying play. Unfortunately, it went the other way."
Stalock recorded his first shutout in 14 NHL games.
"A win is a win on the road, but the first shutout is pretty special, something to remember," Stalock said.
Stalock played his 11th game of the season to give starting goalie Antti Niemi a rest and made the most of his opportunity.
"The goaltender was fine. A big save at 1-0, then back the other way for 2. We'll take it," Sharks coach Todd McLellan said.
Thomas made 36 saves for the Panthers.
The Sharks, who defeated Washington 2-1 on Tuesday, won consecutive road games for the first time since taking three straight Nov. 12-15. They beat the Panthers for the first time in five games, dating to the 2008-09 season.
The Sharks stretched their lead to 3-0 when Pavelski poked a rebound into the net at 11:46 of the third. Pavelski leads the Sharks with 22 goals and has 13 points in his past 13 games.
San Jose took a 1-0 lead in the second on Thornton's breakaway goal. Thornton got a loose puck in the neutral zone, skated in on Thomas and put the puck over Thomas's glove with 51 seconds left in the period. Thornton has 15 points in his past 13 games.
"I don't know the last time I had a breakaway," Thornton said. "I wanted to float one in and see if I could catch him off guard and I did."
Thomas stopped 21 shots in the first period, the most in a period against the Panthers since they allowed 21 against Ottawa on Dec. 3, also in the first period.
"Obviously not happy that they were taking it to us pretty hard and they were the team that was ready to play and we weren't," Thomas said. "They're a good team. They looked like a very good team against us tonight."
The Sharks have been the best first-period team in the league with 52 goals, but Thomas was able to keep them out of the net.
The Sharks had a 5-on-3 power play for 1:29 in the first, but the Panthers were able to kill off the penalty. The Panthers haven't allowed a power-play goal in seven games.
The Panthers are 0-for-25 on the power play over the past eight games.
Thornton leads the Sharks with 51 points. ... The Panthers haven't played the Sharks since a 5-3 win on Dec. 3, 2011.
Copyright by STATS LLC and The Associated Press
SUNRISE, FL - JANUARY 16: Goaltender Scott Clemmensen #30 of the Florida Panthers warms up prior to the game...