The Nationals' Daniel Murphy reacts after he hit a go-ahead, two-run single in the eighth inning Sunday night. (Nick Wass/AP)

Daniel Murphy raised his right arm before he reached first base, knowing he had given the Washington Nationals the lead they so desperately wanted Sunday night. It was a line drive that just beat the Philadelphia Phillies’ infield shift in the eighth, just carrying over the leaping second baseman’s head in shallow right field. It scored two runs and proved to be the game-winning hit in the Nationals’ 8-6 comeback victory. It concluded a night that might have veered Murphy back on his usual track after an eight-month layoff.

The single was Murphy’s third of the game. He also walked once. After reaching base six times in his first 11 games back from microfracture knee surgery, the 2016 National League MVP runner-up reached base four times in five plate appearances. After a couple sloppy losses, the effort helped save the Nationals (41-35) from an ugly sweep at the hands of a surging divisional foe.

“This is a great win for us,” Nationals Manager Dave Martinez said.

Brian Goodwin initiated the eighth-inning surge with a pinch-hit walk. Two batters later, Bryce Harper whacked a line drive to right field that he stretched into a double, just beating the throw at second base. The hustle double — Harper’s career-high third double of the game — sparked the slugger. He turned to the Nationals’ dugout to unleash a scream. He pumped his fist. Harper, struggling mightily in June, was revived.

After Anthony Rendon grounded out, the Phillies (41-34) decided to intentionally walk Juan Soto with first base open. It would have been an unimaginable scenario just a couple months ago; the 19-year-old Soto getting a free pass and loading the bases for Murphy, one of baseball’s premier hitters the last two seasons. But Soto is the one playing at an all-star level, so Philadelphia chose to have Murphy, who entered Sunday with a .135 batting average and .320 on-base-plus-slugging percentage, face the hard-throwing Seranthony Dominguez.

“Soto has been one of the league’s most dangerous offensive players,” Phillies Manager Gabe Kapler said. “Murphy, coming off injury and sort of still going through the process of getting back to being Murphy, has struggled. And with Seranthony’s fastball, it’s not an easy fastball to catch up with and we thought that Soto was more dangerous in that situation. You pick your poison right there. You have two very good hitters and the first one in Soto has been elite and Murphy has struggled a little bit. So went after the guy who’s struggled and coming off injury.”

“Good play,” Murphy said when asked about the Phillies’ strategy.

Murphy fell behind in the count 1-2 before scooping a slider down and out of the strike zone to right field to drive in Goodwin and Harper. Michael A. Taylor followed with another single to score Soto for his third hit of the game as the Nationals collected 17 in total.

“It was awesome … but that inning was made long before I got up,” Murphy said. “I’m the sixth batter of the inning right there and there were some great at-bats that were had in front of me to get it started.”

The Nationals were facing a deficit because their manager’s decision-making backfired in the fifth inning.

Martinez had a choice to make coming out of a 38-minute rain delay in the fourth inning. He could keep Jefry Rodriguez, his starting pitcher, in the game to hit for himself with two outs and two runners on base, or he could replace him with a pinch hitter. The score was tied in the fourth. Rodriguez had thrown 81 pitches. Inserting a pinch hitter would boost the chances of seizing the lead and Rodriguez had, at most, another inning left in him in his fourth career start.

But Martinez decided to stick with his pitcher. He wanted to avoid using the bullpen that early and preserve his four-man bench. Regardless, the decision flopped. After Rodriguez struck out to terminate Washington’s scoring opportunity, he walked the leadoff hitter in the fifth inning and hit the next batter. The sequence prompted Martinez to relieve him with left-hander Sammy Solis to face the left-handed-hitting Odubel Herrera. That encounter concluded with Herrera, one of baseball’s hottest hitters, smacking a curveball for a two-run triple down the right field line. A couple of batters later, Nick Williams demolished another curveball for a two-run home run. Suddenly, the Phillies had a four-run lead.

“You’re going into the top of the fifth inning,” Martinez said. “Our bullpen’s been taxed, they really are, so I felt comfortable leaving him in, see what he can do. He’s got good stuff, he really does. When he learns how to throw strike one and get ahead and finish, he’s going to help us win a lot of games.”

Making his third career start, the 25-year-old Rodriguez labored. He needed 96 pitches in four-plus innings. Even his 1-2-3 second inning required 24 pitches. He didn’t throw a change-up after the first inning, relying exclusively on his fastball and curveball. The approach cost him in the third inning, which his counterpart, Nick Pivetta, led off with a single. Two batters later, Rhys Hoskins walloped a 94 mph fastball over the wall in right-center field for a two-run home run.

Meanwhile, Pivetta, the prospect Washington relinquished for Jonathan Papelbon two summers ago, wasn’t wasting pitches. The right-hander threw 39 pitches through three innings. Eight were balls. He struck out Harper on a curveball in the dirt in the first inning and on a 97 mph pitch up and away in the third inning. He was, for three innings, nearly untouchable against a Nationals offense that has made several pitchers seem untouchable recently. Then the switch flipped as rain began soaking the diamond in the fourth inning.

The sudden shift began with Rendon smacking his second home run in two days to lead off the inning. Soto then slapped a groundball through the left side against the shift with the count full, the teenager once again displaying his incredible-for-any-age two-strike approach. Murphy and Taylor each followed with singles. Taylor’s hit scored Soto to tie the game, and the Nationals were pushing for more against Pivetta. Then the rain intensified, prompting a delay that effectively suppressed the rally.

When the game resumed, Pivetta took the mound and struck out three consecutive batters, including Rodriguez, to end the inning. It seemed, at the moment, like a turning point from which the Nationals wouldn’t recover. They were wasting scoring opportunities. They appeared destined to get swept. But then Murphy provided the lift they needed.