The eighth inning came like a movie villain. So often this season, it has burned the Washington Nationals’ bullpen. On Thursday, at the end of a frustrating, lengthy homestand, in the depths of the team’s worst stretch under Manager Dave Martinez, it seemed ready to strike again. With two outs and the bases loaded, closer Sean Doolittle faced St. Louis Cardinals pinch-hitter Paul Goldschmidt, one of the game’s most feared hitters.

Goldschmidt fouled off the first two fastballs straight back. He launched the third high and far, but wide of the left-field foul pole. Doolittle was up 0-2 in the count and likely couldn’t have felt worse. Goldschmidt let the fourth go, outside for a ball, and tried to check his swing on the fifth, but he couldn’t. The first base umpire rung him up. Doolittle twisted his cap and puffed both cheeks as he walked off the mound.

Doolittle navigated around a leadoff single in the ninth and the Nationals averted a disastrous finish to this series with a 2-1 win. They also avoided a seventh loss in eight games and being swept in a four-game series at home for the first time since 2009.

The victory was a respite from a 13-17 start marked by injuries to star players, call-ups, reconfigured lineups and a turnstile bullpen.

In the past few days, Martinez has sensed his team press as it tried to escape the cycle. His young players sought to change the team’s fortunes in one play. His role players strained to become the everyday players injuries necessitated.

On Thursday, the manager tried to press a reset button. He counseled rookie shortstop Carter Kieboom, who since being called up last Thursday appeared to have abandoned the patient hitting approach Martinez saw in spring training, on remaining calm and left him out of the lineup. He scratched left fielder Juan Soto from the lineup shortly before first pitch for the second night in a row because of back spasms. He debated a new offensive approach “trying to play for that one run early or things of that nature.”

Before the game, mired in the toughest stretch of his managerial career, staring down a three-city, 10-day trip against the division-leading Los Angeles Dodgers and Philadelphia Phillies, as well as the Milwaukee Brewers and red-hot reigning National League MVP Christian Yelich , Martinez described how he’s trying to guide his team through this early storm.

“For me, it’s about staying positive with the guys, really,” he said. “You’ve got to keep these guys positive through this stuff.”

Ultimately, though, the manager looking for buttons to push just watched as his No. 2 starter, Stephen Strasburg, put the team on his shoulders. The right-hander allowed his lone run in the third inning, when Cardinals second baseman Kolten Wong singled in shortstop Yairo Munoz to give the Cardinals the early lead, but he limited the harm and mostly cruised from there.

The game turned in the fourth when, after a pair of singles, Nationals catcher Yan Gomes smacked a grounder at Munoz. The Cardinals shortstop bobbled it, then threw it away, an error that ultimately would result in two runs, one on that play and another on the next, when Munoz turned a double play while allowing the runner to score from third.

Unlike earlier in the series, the Cardinals were the ones who failed to execute simple plays in the field and the Nationals were the ones taking advantage.

Strasburg (3-1) inherited a rarity for Nationals starters this series, a lead to protect, and he responded by shutting down the Cardinals after the Nationals took the lead. To end the fifth, the 30-year-old dispatched Cardinals pitcher Dakota Hudson for 1,500th career strikeout. Strasburg needed the fewest innings in MLB history to reach that mark (1,272 1/3 ), topping Red Sox lefty Chris Sale (1,290). Strasburg churned into the bottom of the seventh, but a single that bounced off his lower right leg and a walk ended his night. He had left the door open.

But the bullpen, not for the last time Thursday night, came in and slammed it, sending the Nationals out on the road with a much-needed win.