The win completed a three-game sweep and left the Dodgers 1 1/2 games behind the first-place D-backs after a 7-2 road trip against National League West rivals Arizona, San Francisco and Colorado.
"I didn't even realize we are at .500," said Ellis, who went 3-for-6 with two RBIs and had nine RBIs on the trip. "It's awesome. I hope it's the last time we sit at that number and we get over it tomorrow. We might be the only team in baseball not looking forward 100 percent to the break.
"The rest of the division has seen where we're at and the type of team they're competing with, but we're not in first place. They are across the way, and San Francisco's not out of it and Colorado plays us tough. It's far from over in the NL West, where it's always tough."
The Dodgers have gone 15-3 and picked up eight games in the standings since June 22, when they trailed by 9 1/2 games. No Dodgers team has trailed by that many and finished first.
"Seeing the confidence is the biggest thing," said manager Don Mattingly, who had to use backup catcher Tim Federowicz at first base because he used up a bench that was shorthanded with Skip Schumaker serving the first game of a two-game suspension. "I really felt before we got here we had gotten ourselves back in the race and we knew it. This is just icing on the cake. We could have gone backward just as easily."
The Dodgers leaned heavily on Ramirez, who went 3-for-6 with three RBIs and two runs scored. He has eight homers in only 35 games and is batting .409.
"He's been pretty amazing," said Mattingly. "He's been on a mission all year."
"When he came back from the WBC, he was a totally different person," said A.J. Ellis. "He had the passion to play and lead in the middle of the diamond. Deep into extra innings tonight he was pushing us in the dugout. He's as special a hitter as I've ever played with and a big reason why we're at where we're at."
But along with the offensive fixtures, Mattingly had to get creative with his roster to outlast Arizona, He used Monday night starting pitcher Zack Greinke to pinch-hit (he walked). He used rookie reliever Chris Withrow for three innings and Jansen for two. He doesn't have a true long reliever and Chris Capuano had flown home earlier Wednesday to be rested for his start Thursday night.
"Compete zeros," Jansen said of the Dodgers relief corps. "People have been talking trash about our bullpen, but we keep grinding and we don't give up. All of us are warriors and I'm proud of all of us. I hope we keep going and be one of the best in the league."
J.P. Howell, Ronald Belisario, rookie Jose Dominguez and Paco Rodriguez followed starter Hyun-Jin Ryu. Dominguez lit up the radar gun with six fastballs at 100 mph, one at 99 mph, and 11 strikes out of 12 pitches. The only reliever who did not pitch was Brandon League.
Withrow said it was the first time he had thrown as many as three innings since early last year, when the Dodgers turned him from starter to reliever.
"Actually, I felt pretty good," he said.
"Chris Withrow, to me, was the real hero," said Ellis, who also singled home the tying run in the top of the ninth inning. "For a guy just getting his feet wet in the Major Leagues, it shows a lot about his makeup and character and his future in the big leagues."
The Dodgers had nobody on base with two outs in the ninth inning when they tied the game at 5 off closer Heath Bell on a nine-pitch walk by Adrian Gonzalez and singles from Ramirez and A.J. Ellis.
"I've faced him a lot and he knows me pretty well," Bell said of Gonzalez, his former Padres teammate. "The pitch just got away from me and I ended up walking him. I was going right after him, missed a few pitches and he fouled off a bunch. It was just a good at-bat all-around. I felt like I could get Hanley out but it didn't happen that way. I feel really bad because I let everybody down. We definitely should've won that game."
Gonzalez, an All-Star Final Vote candidate, slugged his 14th homer, and fourth of the trip, in the seventh inning off David Hernandez to cut the margin to one run.
Ryu was unable to protect a 3-2 lead provided by Ramirez's two-run double as he served up a two-run double to Paul Goldschmidt in a three-run fifth inning.
The top three hitters in the D-backs order -- A.J. Pollock, Aaron Hill and Goldschmidt -- went 5-for-7 with three extra-base hits, a walk, sacrifice fly and four RBIs against Ryu.
"This was my worst outing so far," said Ryu. "After the team came back to get us on top, I did what a starting pitcher shouldn't do."