PHOENIX — Chris Herrmann hit a game-ending RBI single in the 10th inning, and the Arizona Diamondbacks rallied to beat the St. Louis Cardinals 6-5 on Tuesday night.

The surging Diamondbacks scored two in the eighth and one in the ninth to force extra innings. They have won four in a row and 13 of 15.

Rey Fuentes opened the Arizona 10th with a single and advanced on a sacrifice by pinch-hitting pitcher Zack Godley. Herrmann singled off Matt Bowman (1-3).

Diamondbacks closer Fernando Rodney (2-2) pitched a 1-2-3 10th inning for the win.

Carlos Martinez struck out 10 while pitching six sharp innings, and the Cardinals used throwing errors by catcher Chris Iannetta, pitcher Taijuan Walker and shortstop Nick Ahmed to open a 5-2 lead in the seventh.

With no outs and the bases loaded, Stephen Piscotty singled sharply off the leg of Walker to break a 2-2 tie. Jedd Gyorko added a sacrifice fly, and Ahmed bobbled the relay on Yadier Molina's long single to allow Tommy Pham to score the inning's third run.

Arizona responded with two in the eighth. Daniel Descalso singled in Jake Lamb and came around to score on Herrman's sacrifice fly.

David Peralta then led off the bottom of the ninth with a home run off Cardinals closer Seung Hwan Oh, tying it at 5.

Martinez allowed two runs on Iannetta's two-run double with two out in the sixth. He surrendered four hits and walked three.

Walker was charged with five runs, three earned, and six hits in 6 1 /3 innings. He had no strikeouts and walked five.

FEEL THE GLOVE

Pham robbed Iannetta of extra bases with a catch against the wall in centre field in the second. Randall Grichuk made a diving grab on Herrmann's pinch-hit liner to left in the eighth.

SOME CONCERN

Ahmed departed after he was hit on his right hand by a pitch from Trevor Rosenthal in the eighth.

DIAZ'S DAY

Aledmys Diaz was out of the starting lineup because Cardinals manager Mike Matheny said he isn't seeing the ball well. Diaz entered in the 10th at shortstop.

"He's committing early, way before he's had a chance to get any kind of pitch recognition. Hitters go through that, and it's just no fun," Matheny said.

SHIPLEY COMES IN

The Diamondbacks called up right-hander Braden Shipley from Triple-A Reno. Shipley pitched a scoreless inning against the Cardinals.

Shipley will serve as a long man in Arizona's bullpen for the short term. He also has started twice this season for the Diamondbacks.

Shipley takes the roster spot of reliever Silvino Bracho, who was sent down following Monday's game.

INJURED FAN

A fan was struck in the head by a foul ball off the bat of the Cardinals' Greg Garcia in the second inning and taken to a hospital.

Garcia hit a liner into a section of seats not protected by the screen above the Diamondbacks' dugout, and the fan required medical attention.

The incident caused a short delay on the field, with players from both teams stopping to look into the stands, and the Diamondbacks passed a towel from the dugout up through the crowd to where the man was sitting. He was responsive, and after a few minutes and the resumption of the game, was able to stand and walk out of the seating area with some assistance.

TRAINER'S ROOM

Diamondbacks: Manager Torey Lovullo said he would like OF A.J. Pollock (strained right groin) to play at least seven innings in rehab games at Triple-A Reno this week. ... Lovullo feels OF Yasmany Tomas (right groin tendinitis) will need some rehab at-bats before being ready to return. Tomas is presently working out with the team.

UP NEXT

Cardinals: Adam Wainwright (7-5) is scheduled to start Wednesday. He is 7-4 in 13 career appearances against Arizona, with a 2.71 ERA.

Diamondbacks: RHP Godley faces the Cardinals for the first time in his career. He has not allowed more than three runs in any of his nine starts this season and is 3-1 with a 2.53 ERA overall.