PHILADELPHIA (AP) -- Casper Wells never expected to be warming up in the bullpen in the wee hours of the morning.
However, the Phillies' outfielder was forced into pitching duties against the Diamondbacks in a record-setting, marathon game that ended when Arizona scored five runs off Wells in the 18th inning and beat Philadelphia 12-7 Saturday night.
The teams combined to use 20 pitchers in a contest that ended at 2:12 a.m. and took 7 hours, 6 minutes -- setting a mark for length of game for both teams. It was the longest game by time since the Dodgers and Astros played eight minutes longer on June 3, 1989, according to STATS.
"It was quite a night, surreal is probably a good word for the whole night in general," said Wells, who went 0 for 7. "I was just trying to throw strikes. I used to pitch when I was younger. I was trying to compete. I took it serious."
The 18 innings also matched the longest game in Diamondbacks history in terms of innings, though the Phillies fell short of the 21-inning club record set in 1918. The teams combined for 137 at-bats, 35 hits, 32 strikeouts and 28 walks. Both teams used 22 of their available 25 players, with only three starting pitchers for each going unused.
"It's something I've never done before, and probably never will do again," Phillies outfielder Darin Ruf said. "You never know what you're going to see in the game of baseball."
The Phillies began the 18th with Wells (0-1) on the mound.
"When position players start to pitch, it gets a different feel," Ruf said. "But you still try to win."
Arizona's Cliff Pennington, who had five walks, added: "When Casper went in, I thought, 'This is crazy.'"
After retiring the first two batters, Wells walked Tony Campana to start Arizona's five-run inning. With Campana running, Eaton lined a double to left-center to put Arizona in front 8-7.
After Wells intentionally walked Paul Goldschmidt, Martin Prado drove in Eaton with a single to right to give the Diamondbacks a two-run advantage. Gerardo Parra broke the game open with a two-run single that spelled the end for Wells, who was replaced by another position player, infielder John McDonald.
Wells threw a fastball that reached 91 mph and said he threw two change-ups. But he didn't have enough to keep the Diamondbacks off the board.
"I definitely felt pretty good, but they're major league hitters," Wells said. "If I had a deeper arsenal, maybe I could've kept them off balance a little bit."
The Phillies couldn't score in the bottom of the frame off Trevor Cahill (5-10), who pitched four scoreless innings in his first career relief appearance.
Asked if he could've continued, Cahill said, "I sure hope so, but I'm glad I didn't have to find out."
The series finale will be played Sunday less than 12 hours after Ruf lined out for the final out.
The Phillies will use right-hander Roy Halladay in Sunday's 1:35 p.m. game. Halladay (2-4, 8.65) will be making his first start since May 5 due to shoulder surgery. He was scheduled to make a minor-league rehab start Sunday, but will fill in for Tyler Cloyd, who was scheduled to start but was used as a reliever for five innings Saturday.
Prado homered and drove in three runs for the Diamondbacks, who snapped a three-game losing streak. Parra went 5 for 9 with three RBIs and Easton had four hits and drove in two runs.
Roger Bernadina, Ruf and Carlos Ruiz homered for Philadelphia, which was vying for its fourth straight victory in walkoff fashion.
The Phillies had several chances to do it in the extra innings.
Cloyd, who pitched five scoreless innings of relief, led off the 16th with a double, just his second career hit in 23 at-bats. But the Phillies couldn't advance him. In the 14th, Ruf doubled with one out and went to third on a fielder's choice, but Michael Young grounded out with a chance to win it. In the 13th, Cloyd grounded out to strand the bases loaded.
Arizona also had its chances after regulation.
The Diamondbacks loaded the bases with two outs in the 12th, but Prado popped out, and Tuffy Gosewisch flew out in the 13th with runners on first and third.
It looked as if it was going to be an easy victory for Arizona before Philadelphia rallied for four runs in the eighth. Ruf highlighted the inning, continuing his hot streak by homering in his third straight game and ninth time in August with a two-run shot that tied it at 7.