PHOENIX -- Royce Clayton wanted to help his teammates atone for a two-error inning that allowed San Diego to score five runs. He got his chance when it counted most.
"It's uncharacteristic of our club to give a team extra outs, and we felt bad," the shortstop said. "(Brad) Halsey was pitching a good game, and that kind of put him in the hole a little bit, but we battled back."
Clayton and Craig Counsell, who tied it at 9 with an RBI single, got their hits off Dennys Reyes. But the loss went to Akinori Otsuka (1-3), who faced just three batters and gave up three runs on two singles and a walk.
Otsuka departed after loading the bases. After Counsell's single, Reyes threw a wild pitch that allowed Chad Tracy to score the go-ahead run and Clayton followed with his single to make it 12-9.
"At a time when we're struggling a little bit with our pitching, the offense has really picked it up," Diamondbacks manager Bob Melvin said. "I mean, we're putting crooked numbers up there and all kinds of good stuff. It can be demoralizing when you have a lead, and all of a sudden you're tied. Then all of a sudden you're behind."
Jose Valverde (1-1) got the win despite giving up a run in the eighth inning, and Brian Bruney earned his fifth save in eight chances despite allowing Khalil Greene's two-run triple in the ninth. Geoff Blum flied to right to end the game.
Ramon Hernandez had three RBI for the Padres, who had won nine of their last 11, and Ryan Klesko and Xavier Nady each drove in two.
Troy Glaus, Tony Clark and Luis Terrero homered in Arizona's five-run fifth inning, the 10th three-homer inning for the franchise and first since Sept. 28, 2002, against Colorado.
Glaus and Clark, who also had a two-run double, hit their shots in succession -- a first for the club this year. The most recent of 47 previous back-to-back homers was by Scott Hairston and Luis Gonzalez on July 26 at Houston.
But the Padres responded quickly, scoring twice in the seventh to tie it at 8 on Hernandez's two-run double against reliever Javier Lopez.
Halsey allowed six runs -- one earned -- on eight hits and a walk in six innings.
Darrell May went 4 1/3 innings for the Padres, giving up six runs and eight hits, including Glaus' two-run shot that ended his outing.
"The guys have done an outstanding job for 27 outs to continue to battle," Clark said. "I think any championship team does that, and that's why they didn't throw in the towel either."
Clark connected off reliever Rudy Seanez, and Terrero followed one batter later.
"Sometimes you play a game that goes back and forth," Phil Nevin said. "Obviously, tonight they got the last big hit."
The Diamondbacks led 3-1 from the first inning to the fifth, when the Padres took advantage of two errors by Arizona, which went in leading the majors in fielding, and a pair of bloop singles to right field to score five unearned runs.
The rally started when Sean Burroughs led off with a grounder that Counsell let go between his legs at second. After May struck out, Greene singled and Blum hit an RBI single.
Klesko, the next batter, was safe at first when Halsey failed to touch first after Counsell threw him the ball, and Nevin tied it at 3 with a run-scoring blooper that popped out of the mitt of diving right fielder Jose Cruz Jr.
Halsey walked Hernandez on five pitches to force in the go-ahead run, and Nady blooped a two-run single in front of Cruz to make it 6-3. However, Cruz threw out Nady at second for the final out.
Klesko had an RBI groundout in the first inning, but Arizona answered in its half on Clark's double and Cruz's groundout RBI.
"We did a great job of coming back a couple times. We just couldn't hold them," Padres manager Bruce Bochy said.
Seanez's string of scoreless innings ended at 13 2/3 when Clark, his first batter, homered. ... Hernandez extended his career-best hitting streak to 12 games. ... Greene matched his career high with four hits. His other four-hit game was last Aug. 13 against Cincinnati. ... Terrero matched his career high with three hits. ... The Diamondbacks had season highs for runs and hits (15).