Diamondbacks pitcher Eduardo Rodríguez has seen the biggest improvement, going from a 5.94 ERA to a 4.06 in the second half. (Photo by Jason Miller/Getty Images)

PHOENIX — In the blink of an eye, the Arizona Diamondbacks are knocking on the door of a wild card spot with two weeks remaining in a season where a playoff berth once appeared to be a lost cause.

On July 31, the Diamondbacks were 51-58 and traded away Josh Naylor, Eugenio Suarez, Merrill Kelly, Shelby Miller and Randal Grichuk at the MLB trade deadline. They were nine games out of a National League wild card spot and seemed destined for a disappointing season defined by injuries.

Since then, the Diamondbacks have defied odds by going 26-17, the fifth best record in baseball. Their 6-5 walk-off win Tuesday night against the San Francisco Giants on a ball that never travelled out of the infield kept Arizona 1.5 games out of a playoff spot with 10 games remaining in the regular season.

The biggest difference for the Diamondbacks in the second half? The pitching staff.

“It’s a culmination of the whole year’s work,” starting pitcher Ryne Nelson said. “It’s coming together at the right time and I think it’s the starters for sure. We’ve tried to become a little bit more of a unit and really pull for each other. You’re going out there and watching each other warm up before the games and just supporting each other and having each other’s backs.”

Heading into the All-Star break, the Diamondbacks had a 4.65 team ERA, the fifth worst in MLB at the time. Since the break, the Diamondbacks have pitched to the 10th best ERA at 4.09.

The biggest improvements have materialized from the starting rotation. The rotation’s 0.6-run drop from a 4.47 ERA in the first half to 3.87 in the second half is the sixth-highest drop in baseball.

“We switched gears a little bit,” manager Torey Lovullo said. “At the beginning of the year, we were attacking weaknesses of the hitters, and now there’s a blend of focusing on your strengths and what you’re good at with the ability to attack weaknesses of the hitter.”

By focusing on each players’ strengths, the rotation has given up significantly less hard contact. Hitters’ barrel rates against Diamondbacks starters have nearly been cut in half from 10.7% to 6.1%. Their home runs-per-fly ball allowed has also dropped from 14.2% to 9.9%.

“The first and most important ingredient of our starting pitcher taking them out is what am I good at and how am I going to attack?” Lovullo said. “Then part two of that is blending in where are the weaknesses of the hitter. Prior to that, we had been really cycling through attacking weakness from the very first pitch on.”

Of the four main starters who have stayed healthy and made it through the trade deadline — Nelson, Eduardo Rodríguez, Zac Gallen and Brandon Pfaadt — only Nelson had an ERA below five in the first half. Since the All-Star break, only Pfaadt and Rodríguez have an ERA north of four.

Rodríguez has seen the biggest improvement, improving from a 5.94 ERA to a 4.06 in the second half. Lovullo notes that Rodríguez’s ability to not panic, have a slow heartbeat and make adjustments after bad pitches are among the reasons he has improved as the season progressed.

“The reason why he’s having success, for me, is the location of his pitches,” Lovullo said. “He’s landing it in the right spot, the depth of his breaking ball, reading swings, changing speeds with the changeup and the breaking ball, and just making pitches when he has to and limiting mistakes for sure.”

In the bullpen, the improvements are more subtle. The 4.44 bullpen ERA in the second half is still in the bottom half in the league, overshadowing the fact that it’s the sixth biggest drop from the first half to the second (4.94 in the first half).

Similar to the rotation, the key to the bullpen’s new found success since the All-Star break is limiting hard contact. Hitters’ barrel rates went from 8.9% in the first half to 6.8% in the second.

“Guys are attacking the zone,” catcher James McCann said. “Guys are trusting their pitches and they’re making the pitches when they need to make them.”

It’s also a young bullpen. The Diamondbacks currently have five members in the pen with less than a year of MLB service time.

The inexperience may bring inconsistency, but Lovullo likes the perspective they offer.

“I think they’re egoless,” Lovullo said. “When the phone rings, they don’t know who it’s going to be, and there’s a uniqueness to that feeling. Your stomach is always probably churning and wondering when it is your turn, you’re equipped and ready because you’ve never really turned off your motor from the fifth inning on.

“When I put player A in the game, player B has no curiosity as to why it’s not him. And then the next night, I might shift the deck and put player B in the game, he has zero curiosity as to why it wasn’t him. So that’s where I say there are no egos. There is nobody that’s trying to get in the way of one another through performance or frustrations. I think they’re just laid down, and when the phone rings, they’re all very eager to go in there, and they’re ready to go.”

It’s a pitching staff that collectively lowered its ERA by 0.2 runs in its last 43 games, despite losing key pieces to injury and a mainstay in the rotation in Kelly at the trade deadline.

Diamondbacks’ ace Corbin Burnes was one of an MLB-leading five players on the Diamondbacks to receive Tommy John surgery, with four of them happening in June alone.

Through all the injuries and struggles, the pitching staff never gave up, and it’s been imperative to the Diamondbacks’ resurgence.

“Our mentality the whole time was that we were never going to count ourselves out and the last thing that we were ever gonna do was just throw in the towel and say we sold, so we’re done,” Nelson said. “We still come out every day and prepare to win and go out there and play with that mentality.”

Follow Cronkite News: Phoenix Sports on Twitter.