Gabriel Bourque and Blake Wheeler also scored for Winnipeg (7-7-0), which was outshot 53-19.
"There was a stretch there where I was praying a little, but the guys were great about letting me see things," said Hellebuyck, who set an NHL career-high in saves. "This is the result of the pucks going my way."
WATCH: [All Jets vs. Sharks highlights]
Barclay Goodrow and Tomas Hertl scored for San Jose (4-9-1), which opened a six-game homestand with a fourth straight loss. Martin Jones made 16 saves.
"We let them hang around, and it's those one or two mistakes you make that come back to haunt you," Sharks forward Evander Kane said. "And that's what happened tonight."
Ehlers gave the Jets a 3-2 lead when he one-timed Jack Roslovic's pass from behind the net past Jones at the right face-off circle for his seventh goal of the season.
"You know what? I thought there might be the other positive [besides Hellebuyck], because Jack Roslovic created that goal, and he needed to because he was so bad through two-and-a-half [periods]," Jets coach Paul Maurice said. "But you know what? Good for him. That's important. You play 82 games, and you're going to have a night where you just can't get it done, it's not going for you. But he didn't sulk, he didn't sit on the bench. He went out, he and [Ehlers] win us the game, along with our goaltender, after a real, real tough night.
"I got a lot more faith in him that there's a young man that's going to stay in the game. He's learned a really valuable lesson; stay in the game, stay in the fight, because you truly can be the difference maker."