PHOENIX (AP) – Arizona pitcher Shelby Miller played left field and chased after Sean Rodriguez’s go-ahead double in the 13th inning before striking out to end the game, and the Pittsburgh Pirates beat the Diamondbacks 12-10 on Sunday.

Miller had to play the outfield after shortstop Nick Ahmed was ejected in the 12th for arguing balls and strikes. Miller is the first Diamondback pitcher to play a position and the first major leaguer to do so since Jason Gurka played right field for the Colorado Rockies on Sept. 15, STATS said.

The Pirates had a season-high 20 hits and built a five-run lead after three innings, but Arizona scored twice in the eighth and Paul Goldschmidt tied it in the ninth with a two-run homer, his second of the game.

Pittsburgh scored twice in the 12th to go up 10-8, but Neftali Feliz (1-0) couldn’t hold that lead.

Rodriguez lined his double off the wall in left off Evan Marshall (0-1), and Jonathon Niese made it 12-10 win a run-scoring single – also to Miller in left.

Arquimedes Caminero closed it out, working around a single in the 13th for his first save.

Miller entered as a pinch-runner for pitcher Zack Greinke in the 12th after Greinke got an infield single as a pinch-hitter.

Join The Conversation On The KDKA Facebook Page
Stay Up To Date, Follow KDKA On Twitter

Arizona’s Welington Castillo hit a three-run homer on his 29th birthday, giving him six homers and 11 RBIs the past seven games. Yasmany Tomas also homered for the Diamondbacks, who had 15 hits.

Gregory Polanco and Jason Rogers drove in two runs each for the Pirates.

Goldschmidt hit a solo homer off Francisco Liriano in the first inning, though it took a second to figure if Polanco caught it or not. The fans in right field saw the ball creep just over the wall and the rest of the crowd joined them in cheering once they finally realized the ball had gone out.

There was some doubt about Castillo’s homer in the third, too. His liner on a 1-2 pitch from Liriano looked as if it might hook too much to stay fair, but it caught the foul pole in left for a three-run homer that put Arizona up 4-3.

Liriano settled in after that, allowing four runs on five hits with six strikeouts.

Arizona starter Robbie Ray labored for the first time this season, giving up five runs on eight hits. He had allowed two earned runs or less in six straight games, dating to last season.

Rogers hit a two-run triple off him in the third inning and Polanco drove in two with a single in Pittsburgh’s five-run third to build an 8-3 lead.

(Copyright 2016 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.)