SAN JOSE, Calif. -- Joe Pavelski was being too creative in the shootout.
He needed something different this time.
"You don't get a chance to do very much," Pavelski said. "There's only a couple of moves you can do. You stop, the puck keeps moving, slow."
Logan Couture scored his first goal in eight games. Patrick Marleau and Martin Havlat also scored for the Sharks, who finished a season-long five-game homestand unbeaten and won their eighth in nine overall.
The Sharks got a scare when Joe Thornton caught a puck over his left eye. He was back on the ice after getting stitched up.
"You hope it's not serious and when we saw where it was, we knew he'd be back," Marleau said. "He played with one eye for the most part."
Thornton wasn't making too much of it.
"I think it was just a ricochet. I'm not sure if somebody tipped it or not, but it caught me right on," he said. "I just came in and got some stitches. But I'm fine. It's what hockey players do. They get bumps and bruises and they come back out."
"We kept coming back at them," Ducks coach Bruce Boudreau said. "We were always within reach. If we scored one, we'd score two. We had our opportunities."
Niemi stopped 28 of 31 shots for his 15th win. Jonas Hiller saved 32 shots in taking the loss.
The Ducks have lost six of their past seven road games.
Lovejoy tied it at 16:54 of the third with his first goal of the season, though he has three points in his past four games.
Nick Bonino won a faceoff in the Sharks zone, tapped the puck to Lovejoy, who shot it to the right corner.
"It's good to win but we made a lot of mistakes," Couture said. "After losing a faceoff we need to get into the shooting lanes. We need to do our job."
Hiller stopped all 12 shots he faced in the first period, including several outstanding saves.
Perry gave the Ducks the early advantage with a shot into the upper right corner 5:56 into the game. Ryan Getzlaf gave him a terrific pass to set up the goal.
Niemi had a solid second period, allowing the Sharks to take the lead.
Couture tied the game at 4:16 of the second. He redirected a shot from Marc-Edouard Vlasic over Hiller's glove. The goal ended a season-long goal scoring drought for the center.
The Sharks took advantage of a poor pass from Hiller to score an easy goal midway through the period for the go-ahead goal.
Hiller came out of the net to clear the puck, but flared it to Marleau's stick, who played give-and-go with Thornton and scored into an empty net at 10:13.
Havlat picked up a rebounded shot and tipped it into the net with less than a minute remaining to put the Sharks up 3-1 entering the final period.
"That's a lot of character when you have guys step up in the third period like that, down two goals against a pretty good hockey team and able to fight back and get that point," Getzlaf said.
Grant, playing in his first NHL game, scored his first goal with 7:10 remaining in the third to bring the Ducks within 3-2. The defenseman took a shot that Niemi blocked with his right shoulder, but was unable to control as it flipped in the air behind him and into the net.
Getzlaf recorded a point in his 10th straight game, his longest streak in four years. ... The Sharks and Ducks played the first of five games in their season series. It was their first meeting since March 27, a span of 249 days. ... Hiller went down for a few moments after teammate Kyle Palmieri accidentally hit him in the side of the head. ... Ducks F Dustin Penner has eight points in his past six games. ... Mike Brown recorded his first assist of the season and his second point.