Andrew Stevenson runs toward third base en route to scoring one of the Nationals’ two sixth-inning runs as part of a four-hit day. (Cary Edmondson/USA Today Sports)

For all the unyielding positivity the Washington Nationals have espoused as they have plodded through a trying first month of the season, any assertion that the lineup they fielded Wednesday afternoon would be the one to finally snap them out of their offensive funk would have drawn eyerolls. Thanks to a series of crippling injuries and a day off for a couple of other mainstays, the lineup featured two Opening Day backups and three others who began the season in the minors.

But baseball is usually unpredictable and sometimes silly. And thus, there was Matt Adams hammering more right-handed pitching, and Andrew Stevenson spraying line drives around the diamond, and Trea Turner smacking five of Washington’s season-high 18 hits as the Nationals avoided a series sweep with a resounding 15-2 rout of the San Francisco Giants at AT&T Park.

By the end of the sun-soaked afternoon, the Nationals scored 14 of their season-best 15 runs with two outs, becoming the first team with that many two-out runs since the New York Yankees tallied 16 with two outs in August 2015. With the firepower, the Nationals snapped a four-game losing streak and finished 4-5 on their nine-game trip. It was a stream of clutch hitting the Nationals were wondering would ever flow their way again.

“That was fun,” Nationals Manager Dave Martinez said.

Of course, the Nationals (11-14) didn’t need an explosion because Max Scherzer was doing the pitching. A club obviously never aspires to a four-game losing streak, but if it’s going to build one, there is arguably no one better to halt it than the man who was caught on camera talking to himself on the mound before he threw a pitch Wednesday. Scherzer is the quintessential stopper, and, though he wasn’t peak Scherzer, less-than-peak Scherzer is still the envy of most.

The two-time defending Cy Young Award winner allowed two runs on five hits in six innings. He walked two and struck out 10 for his 68th career double-digit strikeout total and fourth in six starts this season. His 57 strikeouts this season lead baseball. And yet his ERA rose from 1.36 to 1.62.

“Really got to attack the zone,” Scherzer said. “First-pitch strikes were up, didn’t fall behind too many guys and was mixing pitches.”

Scherzer was given an early cushion after the Nationals scored as many runs in the first inning — three — as they had in a game since Friday. The producers were, of course, fill-ins — and they produced with two outs. Adams, playing first base for Ryan Zimmerman, provided the first knock, an RBI single to center field off Giants right-hander Jeff Samardzija, whom Adams was 7 for 14 in his career against entering the day. After Michael A. Taylor walked, Stevenson, who was making his first major league start in 2018, drilled a two-strike, two-out, two-run double.

Washington landed the next blow in the fourth, when the Giants’ fear of Bryce Harper cost them. Through Harper had been mired in a personal slump — he entered the game 2 for his past 21 — San Francisco was still avoiding him when possible. On Tuesday night, with one out and first base open in the eighth inning of a one-run game, the Giants intentionally walked him. The strategy worked; Zimmerman grounded into an inning-ending double play.

They tried the approach again in the fourth inning Wednesday when Samardzija fell behind — and instead of making a 3-0 mistake with two outs, the Giants (11-13) called for an intentional walk. But Adams, not Zimmerman, was protecting Harper on Wednesday and his destruction of Samardzija continued with a rocket over the right field wall for a three-run home run, part of a 3-for-5 performance with six RBI, which matched a career high.

“A lot of his stuff comes into me, with that little cutter,” Adams said of Samardzija. “And he goes front door with his fastball out. Today I just told myself to stay tight, stay connected, and I was able to get the barrel to the ball and do some damage.”

An inning later, Turner’s groundball bounced off a diving Brandon Belt’s glove at first base for a two-run single to give Washington an 8-1 lead and blow the game open. It was the third of Turner’s five hits, a mark he reached for the second time in his career.

Stevenson, who entered the game with 10 career hits, added another RBI double in the sixth inning for his fourth hit in four at-bats. He later walked in a run and finished his breakout day 4 for 5 with two doubles, a walk, four RBI and two runs.

“That gives you a little confidence, to prove you belong out there,” Stevenson said. “That was a good win today, and we needed it.”

About the only intrigue remaining was whether Scherzer’s chase for Joe DiMaggio’s hit-streak crown would end at four games. He finished the sixth inning at 99 pitches with an eight-run lead, but the Nationals were hoping to stretch him to 110 pitches. So he was given the green light to hit for himself in the seventh and extend a hitting streak in peril after three hitless at-bats. He grounded out. And because the inning was so long — the Nationals sent eight batters to the plate in the frame — Scherzer’s day was over on the mound, too. Not everything went right for the Nationals, but it was close.