The ball flicked off Ian Desmond’s bat in one motion and started on its path toward right field. Bryce Harper broke into a sprint from second base. As Harper slid into home and Hunter Pence’s throw to the plate sailed just wide, a collective sigh of relief from the Washington Nationals seemed to go with it.

One swing, and it cured so many ills.

The Nationals’ finished their West Coast trip with a 2-1 victory in 10 innings over the San Francisco Giants on Wednesday, set up when Harper doubled and Ryan Zimmerman was intentionally walked. Desmond came to the plate thinking one thing: “Just trying to come through,” he said.

With a shout and a hard clap by their 20-year-old outfielder as he crossed the plate, the Nationals moved back to one game above .500, broke a four-game losing streak and avoided a sweep.

“This was a huge step in the right direction,” said Desmond. “There’s nobody out there who can tell me what the Giants record was on May 22 of last year. What [Buster] Posey’s batting average or Matt Cain’s ERA was, without looking it up. That stuff doesn’t matter.

“At the end of the year, when you’re fighting for the postseason, a World Series title, nobody remembers any of that stuff. We’ve got to grind through it and at the end of the day we’re going to look back and no one is going to remember what happened on May 21 or 22.”

Desmond’s single won it for the Nationals, a piece of hitting so impressive manager Davey Johnson said it “seemed like the first time this road trip we got a base hit with a runner in scoring position.”

But on this day, with Gio Gonzalez tossing 7 ⅓ strong innings of work and Rafael Soriano saving his 13th game, it was Harper — at the plate, in the field, with his speed — who willed the Nationals to victory.

“Being able to get a win here and get on a winning streak, hopefully, it’s good for us,” Harper said. “I’m excited to get back to D.C., have a day off, relax and not do anything, and get back home and play in front of our fans where we’re comfortable.”