Niemi made nine saves in the third period to help the Sharks hang on for their fifth win in six games.
Patrick Elias got the Devils' only goal on a third-period power play.
Martin Brodeur made 28 saves for New Jersey, which wrapped up a three-game California road trip with a 2-1-0 mark.
'Happy' fan videos make Pharrell cry [VIDEO]
Pregnant Mila Kunis wins 'Best Villain' at MTV Movie Awards