Updated

Baltimore had a rough night in its series opener against Arizona, blowing a two-run lead before losing on a walk-off homer on the first pitch of the ninth inning.

The second game was even tougher to take.

Paul Goldschmidt hit a tying homer off Baltimore closer Jim Johnson in the ninth inning, then sent T.J. McFarland's first pitch off the 11th inning over the wall in right for the winning homer to send the Orioles to a 4-3 loss to the Diamondbacks on Tuesday night.

Two nights, two walk-off homers on the first pitch of an inning. It doesn't get much tougher than that.

"It is heartbreaking, but we have to forget about it," Johnson said.

Arizona won the series opener 7-6 when Adam Eaton splashed Darren O'Day's first pitch of the ninth inning into Chase Field's pool.

Goldschmidt was due up next in that game and one-upped his teammate with two dramatic homers to give Arizona its 25th win in its last at-bat.

The first came in the ninth, when led off with one off Johnson, the major leagues' saves leader.

Goldschmidt's next at-bat came in the 11th and he wasted no time, lifting the first pitch by McFarland (1-1) just over the wall in right for his 29th homer and second walk-off of the homestand.

It was Arizona's ninth walk-off and 34th comeback victory.

"Goldy, at the end of a game, it's pretty special what he can do," Diamondbacks manager Kirk Gibson said. "He's a good guy to have on your side."

Heath Bell (3-1) worked a perfect 11th inning, and Gerardo Parra hit his career high-tying eighth homer for Arizona.

Baltimore starter Miguel Gonzalez pitched seven effective innings and Chris Davis homered for the second straight game to push his major league-leading total to 44.

J.J. Hardy also homered for the Orioles, but their bullpen failed for the second straight night, leading to another dramatic loss.

"They (the losses) were tough, but you know, we move on," Orioles manager Buck Showalter said.

Gonzalez retired the first 11 batters he faced and had the Diamondbacks off-balance by mixing his low-90s fastball and big curveball.

Gonzalez blew a 3-0 lead in his last start and got into trouble again, this time in the seventh inning.

Aaron Hill got it going with a one-out triple, then scored on Martin Prado's groundout. Parra followed with a solo homer — his first since June 22 — to pull the Diamondbacks within 3-2.

Gonzalez allowed two runs and five hits.

But for the second straight night, Baltimore's bullpen couldn't hold the lead.

Francisco Rodriguez did his part with a perfect eighth, but Johnson blew his AL-leading eighth save when Goldschmidt lined a 3-1 pitch over the wall in left-center. It was Goldschmidt's fifth homer in the ninth inning, most in the majors.

Goldschmidt ended it in dramatic fashion, squeezing a drive just over the wall for his fourth career game-ending hit before being mobbed by teammates at the plate. Goldschmidt also hit a walkoff homer against the Mets on Friday.

"Looking at what the guys have been putting into the game and the way the game unfolded, it was heartbreaking, but we have to forget about it," Johnson said.

Notes: Davis leads the majors with 43 extra-base hits on the road. ... Davis moved into fourth on Baltimore's all-time single-season homers list and is two behind Jim Gentile (1961) for third. ... Arizona LHP Patrick Corbin, an NL All-Star, is 0-2 with a 2.70 ERA in his past three starts. He will start Wednesday's series finale. ... RHP Chris Tillman, who will start Wednesday against Arizona, is 7-1 with a 2.97 ERA in 10 road starts this season.