ST. LOUIS — Jack Flaherty won a fourth straight start for the first time in two years, and the St. Louis Cardinals beat Washington 8-4 on Sunday to open the second half by taking two of three from the Nationals.

Paul Goldschmidt hit a two-run homer and Nolan Gorman had three hits and two RBIs for St. Louis.

Flaherty (7-5) allowed three runs, three hits and three walks in six innings with seven strikeouts. He had not won four starts in a row since an 8-0 stretch from April 7 to May 19, 2021.

“Good things happen when you get ahead,” Flaherty said. “A lot of things that I’ve been trying to work on and get better throughout the year, from getting ahead and fastball command, I did a lot better job of that today.”

The Baltimore Banner thanks its sponsors. Become one.

His hot streak this year followed a slump in which he went 0-1 over five starts.

“Jack, he was on the attack from the first inning,” Cardinals manager Oliver Marmol said. “His stuff looked really good. Commanded the fastball extremely well, got a lot of swing and miss on the curveball, miss on the slider and changeup.”

Chris Stratton pitched a perfect seventh and Kyle Leahy relieved after a 38-minute rain delay. Leahy got one out and JoJo Romero the final five for the Cardinals, who are last in the NL Central at 40-53.

“We just got to play well every day and put a bunch of wins together,” Goldschmidt said. “So, if we do that, we got a chance.”

Nationals All-Star Josiah Gray (6-8) gave up four runs and 10 hits in five innings.

The Baltimore Banner thanks its sponsors. Become one.

“He had traffic from the first inning on,” Nationals manager Dave Martinez said. “He couldn’t really establish his fastball today. He threw a lot more sliders, a lot more cutters. He got out of some jams you know and gave us all he had for five innings. You know, I thought that was enough. He had 95 pitches.”

Keibert Ruiz homered in the second, ending Flaherty’s 13 2/3 innings scoreless streak.

Run-scoring singles by Andrew Knizner, Brendan Donovan and Lars Nootbaar in the fourth built a 3-1 lead for St. Louis, which had gone 0-for-8 with runners in scoring position.

Gorman homered in the fifth.

“He’s taking much better at-bats,” Marmol said of Gorman. “Today was another good day for him. He’s staying on the ball well. Even on the flyouts, you can tell he’s staying through the zone a lot better.”

The Baltimore Banner thanks its sponsors. Become one.

Dominic Smith had a two-run double to shallow center in the sixth that just eluded Nootbar’s attempt for a diving, backhand catch, cutting the Nationals’ deficit to 4-3.

Goldschmidt hit a 443-foot drive to center in the sixth off Jordan Weems, Alec Burleson had an RBI groundout and Gorman added a run-scoring single for an 8-3 lead.

Abrams doubled and scored on Ruiz’s groundout in the eighth.

“We had a good series there,” Flaherty said. “We were a couple of pitches away from taking all three. We’ll take this one, build on it and move on to the next one.”