PHOENIX (AP) -- Languishing deep in last place three months ago, the Los Angeles Dodgers are headed to the playoffs.
The Dodgers became the first team to clinch a postseason berth, wrapping up their first NL West title since 2009 when they rallied past the Arizona Diamondbacks 7-6 on Thursday behind two homers from Hanley Ramirez.
Despite an NL-high payroll of $214 million-plus on opening day, the Dodgers got off to an 30-42 start and were last in the division, 9 1/2 games behind the first-place Diamondbacks, before play on June 22. Los Angeles has gone 58-23 since.
The Dodgers trailed 6-3 in the sixth and A.J. Ellis hit a tiebreaking homer off Josh Collmenter (4-4) leading off the eighth.
J.P. Howell (2-1) got two outs for the victory.
Clinching on the home field of their nearest, but not very near, rival, the Dodgers charged the mound after Aaron Hill flew out to left field for the final out. They mobbed Jansen and the throng bounced out toward second base in continued celebration. A few Diamondbacks watched from the dugout. Most made their way to the clubhouse.
Ramirez, who sat out five of the last six games with an irritated nerve in his lower back, hit a three-run homer in the third inning and a tying solo shot in the seventh. It was his 13th career multihomer game and first since Aug. 18 of last year.
In the ninth, with a sizeable contingent of Dodger fans roaring its approval, Jansen fanned Paul Goldschmidt and Martin Prado before Hill's fly all ended it.
With a new ownership taking over from Frank McCourt on May 1 last year, the Dodgers stumbled this spring and manager Don Mattingly's job appeared to be in jeopardy.
But Los Angeles won 17 of 20 leading into the All-Star break, the first stages of what became a 42-8 run that had the Dodgers 22 games above .500 after a three-game sweep of the Mets on Aug. 17.
Lately, the banged-up team had struggled, losing nine of 12 and five of six entering Thursday's games.
Los Angeles started strong in this one, though.
Arizona starter Wade Miley's troubles in the third began when he walked Dodgers starter Ricky Nolasco to lead off the inning. Yasiel Puig was forced out at second on a throw from right fielder Gerardo Parra after the base runner held up on Jerry Hairston Jr.'s blooper. That brought up Ramirez and he homered to left to make it 3-0.
Nolasco couldn't hold it.
Arizona started the third with four consecutive hits, including an RBI double from Paul Goldschmidt and two-run triple by Prado to tie it at 3. Miguel Montero singled Prado home with the go-ahead run. After Parra's two-out single, Miley's double to deep left-center brought the runners in to make it 6-3.
Los Angeles came back.
Consecutive doubles by Juan Uribe and Scott Van Slyke, followed by Ellis' RBI single cut the lead to 6-5 in the sixth, then Ramirez led off the seventh with his 20th home run of the season, on an 0-2 pitch from Chaz Roe, and it was tied 6-all.
Collmenter came on to get Arizona out of trouble in the seventh, but Ellis, the No. 9 hitter in the Dodgers batting order, sent the first pitch of the eighth just over the fence in left and Los Angeles led 7-6.
Miley went five innings, allowing three runs on five hits with four walks and three strikeouts. Nolasco went five innings, giving up six runs on nine hits.
NOTES: Dodgers 1B Adrian Gonzalez sat out the game with sore quadriceps. ... Los Angeles moves on to San Diego, where RHP Edinson Volquez (9-11, 5.94 ERA) takes the mound for the Dodgers in Friday night's series opener against Padres LHP Robbie Erlin (2-3, 5.18). ... Arizona embarks on its final road trip of the season, with Randall Delgado (5-6, 3.98) going for the Diamondbacks against Colorado's Jholys Chacin (13-9. 3.22). ... The Diamondbacks have three home games left, against Washington Sept. 27-29.