Bryce Harper slams a home run in the sixth inning to stake the Nationals to a 1-0 lead. (Ezra Shaw/Getty Images)

A helmet lay in Bryce Harper’s wake as he slid into home plate late Wednesday afternoon, discarded along with the oddity and injury of the Washington Nationals’ long, strange trip out West. He rose to his feet, spent and satisfied. He clapped once, loud and hard. The 10-day slog had been difficult, but Harper was ending it on his terms.

“It was excitement,” Harper said. “I just tried to fire up the guys and just be excited we won a ballgame.”

In the Nationals’ 2-1, 10-inning victory over the San Francisco Giants, Harper rose above the throbbing pain and minor controversy inflicted on him during the Nationals’ West Coast swing. With a thunderous bat, redemptive defense and, finally, his speed on the bases, Harper grabbed the game by the throat and sent the Nationals back to Washington with a win that snapped a four-game skid.

Gio Gonzalez shut the defending world champions down for 71 / 3 innings, and Harper took care of the rest. Harper smashed an opposite-field home run off side-winding lefty Madison Bumgarner, the 12th homer of his age-20 season. He overcame his hard-earned aversion to outfield walls to make a crucial defensive play against the fence. He roped a double to right in the 10th inning. He scored the game-winning run — sprinting on a swollen knee freshly hurt on a sliding catch two innings earlier — on Ian Desmond’s single off Jeremy Affeldt, sliding in ahead of right fielder Hunter Pence’s throw.

“I was just glad I squared something up, finally, on this road trip,” Harper said. “I just really had been struggling ever since I faced the Braves and hit the wall.

“To square something up and have a few good ABs in this last road game, to get home, it feels very good.”

Gonzalez allowed four hits as he reprised his all-star form. The Giants still sent the game into extra innings with a run off Drew Storen, charged to Gonzalez, in the eighth inning. Once Harper gave the Nationals the lead in the top of the 10th, Rafael Soriano bounced back from his blown save Tuesday night with a 1-2-3 inning. After Roger Bernadina caught Marco Scutaro’s two-out fly ball on the left field warning track, Soriano ripped out his shirttail.

“It’s gonna be a good flight home,” Gonzalez said.

The Nationals’ 10-day trip included all manner of calamities. Harper smashed into the Dodger Stadium outfield fence. Ross Detwiler missed a start with an injured oblique. Wilson Ramos landed on the disabled list with a pulled hamstring, the same injury that prevented Jayson Werth from even making the trip. Reliever Ryan Mattheus broke his throwing hand punching a locker. Soriano blew two saves, and after the second Tuesday night told USA Today his 4-year-old son would have better positioned himself on Harper’s crucial misplay. Their offense scored 2.8 runs per game.

And yet, they finished the trip 4-6, a result they would not have preferred when they left Washington but nowhere near a disaster.

“We’re looking for something that can ignite, can get us going,” center fielder Denard Span said. “This was definitely a good win going into a day off.”

They could thank Gonzalez partly — “Gio pitched an unbelievable game,” Desmond said — and Harper mostly.

In the eighth, Harper made a diving catch in right field that kept the go-ahead run on second base, sliding on the left knee he battered in the collision in Los Angeles. Harper rose slowly and bent at the waist. Back in the dugout after Storen escaped the inning, head athletic trainer Lee Kuntz found Manager Davey Johnson.

“Bryce hurt his knee again,” Kuntz said.

“I don’t want to hear,” Johnson said. “Please don’t tell me that.”

Johnson approached Harper and asked him, “Can you go?”

Harper said yes.

“It’s a little swollen,” Harper said afterward. “I’ll keep doing the same thing on it.”

In the 10th, Harper walked to the plate with one out and roped a double off Affeldt, a tough left-hander, into the right-field corner. Giants Manager Bruce Bochy ordered an intentional walk of Ryan Zimmerman, choosing to face Desmond with the double play in order.

“The numbers may have indicated that was the right move,” Desmond said.

“I was 100 percent confident I was going to get the job done right there.”

Affeldt fed Desmond a 1-1 sinker. Desmond slapped a grounder through the right side. Pence charged and third base coach Trent Jewett windmilled Harper home. Harper rounded third, his helmet flying, and slid home with the go-ahead run.

Harper, who has insisted the effects of his collision with the Dodger Stadium wall has not compromised his hitting, had given the Nationals their first run on his own in the sixth. Bumgarner started him with a ball, and Harper fouled away two pitches to make the count 1-2. Bumgarner tried to sneak an outside sinker past him. He launched this one to left field, into the first few rows over the fence — only the eighth homer Bumgarner had allowed to a left-handed batter in his career.

“I hadn’t faced him but a handful of times, but I think he’s made it clear he’ll play as hard as he can every day,” said Bumgarner, 23. “That’s the kind of player who will bring the best out of you.”