Erik Karlsson scored a 6-on-5 goal at 17:44 of third period to make it 3-1 and spoil Stolarz's chance for a second straight shutout.
Josef Korenar made 23 saves in his first NHL start for the Sharks (18-20-4), who have lost four of five.
The Sharks are in sixth place in the Honda West Division, four points behind the fourth-place St. Louis Blues, who lost to the Colorado Avalanche 4-3 on Wednesday. The Ducks are in eighth place, nine points behind the Blues. The top four teams in the division will qualify for the Stanley Cup Playoffs.
"The most disappointing part is we didn't gain any ground when the guys we're chasing didn't gain any ground," San Jose coach Bob Boughner said.
Ryan Getzlaf, who sat out four of the previous five games with a back injury, gave the Ducks a 1-0 lead at 8:08 of the first period. It was his first goal in 15 games.
Anaheim dumped the puck deep into the San Jose zone. Karlsson got to it first but tried to pass the puck through his legs to teammate Dylan Gambrell. Troy Terry intercepted and had time to skate above the goal line and center a pass to Getzlaf, who scored as he held off Ryan Donato.
"Without picking on one guy or another, but if you ask Karlsson, he'll tell you he's better than that," Boughner said. "We have to make better decisions with the puck and he's guilty of that."
Grant, playing his 300th NHL game, got position in front of the crease and redirected a point shot from Josh Manson for a 2-0 lead at 2:29 of the second period.
"I was just trying to get to the front of the net and Manson made a good play shooting through the traffic," Grant said. "I'll take those any time I can get them."