SAN JOSE — Ryan McDonagh scored his first two goals of the season in a 1:12 span of the second period Thursday night as the Rangers earned a 6-5 win over the Sharks in the final game of a four-city western swing.
The victory by the skidding Blueshirts, who had lost three straight and six of eight overall, sent them into the All-Star break on a good note.
After falling behind 3-2 early in the second period, the Rangers rebounded with three unanswered goals, two by McDonagh and one by Brady Skjei. J.T. Miller scored what proved to be the game-winning goal when he gave the Rangers a 6-4 lead at 18:10 of the third period.
“Our team needed that,’’ said Miller, who had two assists. “It’s a good way to cap it [the road trip] off. Sometimes it’s not pretty, but we did a good job of making plays when we had the opportunities.”
Said Rangers coach Alain Vigneault, “Six goals on the road is not what you’re going to get on a regular basis, but no doubt that having Mac score his first two was important for our team, and to have Brady step up shorthanded — might have been a bounce — but you work for your bounces.”
Ondrej Pavelec recorded 23 saves against the Sharks after making 21 in relief of Henrik Lundqvist on Tuesday. He made his first start for the Rangers since surrendering five goals on 19 shots against the Islanders on Jan. 13.
“Big win for us, but be honest, I had nothing to do with the win tonight,’’ he said. “The guys battled so hard to score six goals on the road, it would have been a crime to lose the game. It was one of those games where I couldn’t make the save to give the guys a breath.”
Center Kevin Hayes, back in the lineup after missing six games with a deep leg bruise, scored his 11th goal on a slapper from the left circle to open the scoring at 5:45 of the first, then fed McDonagh, who was driving to the net, with a pretty diagonal pass to forge a 3-3 tie at 11:04 of the second.
“Having Kevin back and playing the way he did, with J.T. and Zukie [Mats Zuccarello], was a big boost for us,” Vigneault said.
With Timo Meier in the penalty box, McDonagh’s low wrister deflected off a skate, through a screen and off the post past Aaron Dell at 12:16. It was the third two-goal game of the defenseman’s career.
Skjei then was credited with an unassisted shorthanded goal when he drove the net for a rebound and an attempted clearing pass caromed off his leg and past Dell at 17:09.
In the third, after some around-the-horn passing, Marc-Edouard Vlasic scored on a short-side wrister from the left dot with 9:09 left to trim the Rangers’ lead to 5-4.
But Zuccarello took the puck around the net and found Miller, who hammered his pass home for the two-goal lead with 1:50 to play in regulation. Miller had been benched for the second and third periods Tuesday for some poor defensive play.
Tomas Hertl scored with 49.7 seconds left to keep the Sharks breathing for a while.
“It’s a good feeling,’’ Skjei said, “but we had to fight to the end.”
The Sharks — who were playing without Joe Thornton, who underwent knee surgery for a torn ACL — had been 14-6-3 at home in the Tank. The Rangers rose to 8-12-2 on the road and headed home with a small sense of accomplishment.
“We needed a win,’’ Vigneault said. “I really believe that on this road trip, we played better than our record, 1-3, indicates. Tonight we found a way to get a real strong second, they came at us hard in the third, but we were able to get that extra goal in the end.”