PITTSBURGH (AP) — JT Brubaker pitched five scoreless innings for his first win in nearly three months, and the Pittsburgh Pirates beat the Arizona Diamondbacks 4-2 on Tuesday night.

Brubaker (5-13) allowed four hits with six strikeouts, stranding five runners in scoring position. The 27-year-old right-hander got Diamondbacks starter Madison Bumgarner to line out with the bases loaded in the second and ended a threat with runners on second and third in the third by striking out David Peralta. In the fifth, Pavin Smith was stranded on third when Carson Kelly flew out to center.

“I was focused on the next start," Brubaker said. "The last start was done, it was over with. I had five, six days to get over it. ... Just being able to focus on one pitch at a time really got me in more of a mindset and groove like I was in the beginning of the year.”

Since last winning May 29, Brubaker went 0-9 with a 7.08 ERA in 12 starts.

“I think it just lets you go home and sleep at night a little bit better," Pirates manager Derek Shelton said. “To be able to get that win and to be able to execute, I think it's a big thing for a young pitcher.”

Pittsburgh, which is 0-9 with a chance to sweep this season, has won four of five after taking the first two of the three-game set against Arizona.

Chris Stratton set Arizona down in order in the ninth for his second save of the season.

Bumgarner (7-8), coming off giving up one hit in a season-high eight innings against Philadelphia on Aug. 19, allowed four runs on six hits in six innings.

“I don't feel it was quite as bad as the line looks,” Bumgarner said. “Definitely wasn't sharp, but I think if I could just have a few things to do over, it very easily could've been another one just like the last handful.”

Michael Chavis homered in his second game with the Pirates, sending the first pitch of the third inning, a cutter from Bumgarner, 429 feet into the left-field bleachers for a 1-0 lead. It was his first homer since being acquired in a trade from the Boston Red Sox on July 30.

“I know that I have power,” Chavis said. “One thing I was working on was just letting it happen naturally and stop trying to produce the power. Stop trying to force home runs. Just let them happen."

Ke’Bryan Hayes followed with a triple off the right-field wall and scored on a sacrifice fly from Bryan Reynolds.

Anthony Alford made it 4-0 with a two-run home run, his first of the season, in the fourth. He was reinstated from the 10-day injured list Monday after being inactive since Aug. 12 because of a lower-back strain.

Peralta scaled the left-field wall, trying to bring back Alford’s blast, but came up empty in the stands. He had just denied Kevin Newman of extra bases by making a running catch before colliding with the wall the previous at-bat.

Diamondbacks manager Torey Lovullo said the medical staff assured him Peralta was fine following the collision.

Ketel Marte, pinch hitting for Peralta, cut it to 4-2 with a two-run homer to left in the eighth.

“My frustration is at an all-time high,” Lovullo said. “I have huge expectations of this team. I want them to know that. I want them to know they can go out and win every inch possible on any given night. ... This group goes out every single day to win baseball games. That's all I care about.”

SMITH SUSPENDED

Diamondbacks LHP Caleb Smith was given a 10-game suspension and an undisclosed fine for a foreign substance on his glove in the eighth inning against the Phillies on Aug. 18. Smith has elected to appeal and will remain on the active roster until MLB makes a ruling.

TRAINER’S ROOM

Diamondbacks: OF Kole Calhoun did lower-body work and hit in the batting cage Monday, Lovullo said. Calhoun was placed on the 10-day injured list with a left hamstring strain Aug. 12.

Pirates: C Henry Davis, No. 1 overall pick in the 2021 MLB Draft, was placed on the seven-day injured list because of a right oblique strain with High-A Greensboro.

UP NEXT

Diamondbacks LHP Tyler Gilbert (1-1, 2.04) will take the mound for the finale of the three-game series Wednesday against a Pirates pitcher to be named. Gilbert allowed four runs on nine hits in five innings his last time out on Aug. 20, after no-hitting the Padres in his first major league start Aug. 14.

___

More AP MLB: https://apnews.com/hub/MLB and https://twitter.com/AP_Sports