Yu Darvish wanted to avoid a 3-0 count, and tried to throw his cut fastball on the inside corner of the plate for a strike.

It stayed in the middle of the plate, though, and Didi Gregorius sent it over the right-field fence for a game-tying, two-run homer in the eighth inning.

An inning later, the Texas Rangers were headed to the Chase Field locker rooms in disbelief. The Arizona Diamondbacks had just pulled off a 5-4 victory in walk-off fashion to sweep a doubleheader, handing the Rangers their third straight loss.

The Rangers lost for the first time in 28 games when leading after the seventh inning.

“They’re all tough to swallow,” catcher A.J. Pierzynski said. “Tonight we had a lead going into the eighth inning … just wasn’t meant to be. Made one mistake to Gregorius and it didn’t cost us the game, but it gave them life in the game again.”

The Rangers seemed to have the game in hand until the tide turned suddenly in the eighth.

Darvish had just struck out the side in the seventh, and had strung together six scoreless innings after giving up two runs in the first. But he gave up a leadoff single to pinch-hitter Wil Nieves to start the eighth.

Darvish then struck out Cody Ross before the fateful at-bat against Gregorius, who had an RBI triple in the first. Darvish started him off with two cutters for balls, and then tried to get the third one over for a strike.

“I had to get a strike in there and tried to hit the corner, but he hit it pretty well,” Darvish said through a translator.

Said Pierzynski: “Just a bad pitch. He tried to throw a cutter, just stayed out over the plate and he didn’t miss it. Other than that, he pitched really well.”

It spoiled what had been an impressive night for Darvish. He rebounded from the two runs in the first by retiring 10 straight at one point, and matched his career-high with 14 strikeouts.

But, as Darvish said, “No matter how good you pitch or how bad you pitch, if you don’t win the game, it really doesn’t matter.”