PHOENIX — Finally, the seemingly invincible Los Angeles Dodgers are going through a little rough stretch, and the Arizona Diamondbacks are on a roll.

Paul Goldschmidt homered for the third straight game, Robbie Ray fanned 10 while pitching into the seventh inning and the Diamondbacks held on to beat Los Angeles 6-4 on Wednesday night, sending the Dodgers to their first four-game losing streak of the season.

“Up until this time, we have played very good baseball and had guys step up and be the stopper,” Los Angeles manager Dave Roberts said, “whether at two (losses), three or even one game for us. So yes uncharted territory for this ball club this year.”

Adam Rosales and Chris Herrmann also homered for the Diamondbacks, who have won six straight and eight of nine to pull three games ahead of Colorado for the National League’s top wild-card spot.

“Anytime you’ve got the best team in the league in your facility and you’ve got them on the ropes a little bit and you beat them, I’m really proud of these guys,” Arizona manager Torey Lovullo said, “because the Dodgers never shut down and that’s why they’re a quality team.”

Ray allowed four hits, walked two and hit a batter in 6 2/3 innings. The left-hander reached 10 strikeouts for the seventh time this season.

“I felt like everything was working really well for me,” Ray said, “fastball, offspeed, just keeping them off balance.”

Fernando Rodney pitched a perfect ninth for his second save in two nights and 34th in 39 tries.

Hyun-Jin Ryu (5-7) lasted just four innings, surrendering six runs and eight hits in his first loss since June 5. He had gone 2-0 in six starts since returning from the disabled list.

Los Angeles trailed 6-0 but got a solo home run from Curtis Granderson in the seventh and scored three runs in the eighth, two on Yasiel Puig’s single and another when Archie Bradley walked Austin Barnes with the bases loaded.

Bradley struck out Chase Utley and got pinch-hitter Corey Seager to ground out to first to end the threat.

Los Angeles had been the only team not to lose four straight this season. The Dodgers, who dropped two of three at home to Milwaukee last weekend, have lost consecutive series for the first time since April.

The Diamondbacks will send Zack Greinke to the mound Thursday to try to become the first team to sweep a series from the Dodgers this year.

“It is one thing where you are beating yourself and another thing where this team over there got some momentum,” Roberts said. “They are playing well. They have some energy and they are getting good pitching, we haven’t quite. We haven’t laid down. We would rather take it now than the end of September.”

The Diamondbacks got three in the opening inning against Ryu.

With one out, Rosales hit the first pitch he saw high above the 407-foot sign in straightaway center. Initially it was ruled a triple, but after the umps conferred, they correctly ruled the ball had hit above the home run line on the batter’s eye. A.J. Pollock followed with a walk and Goldschmidt jumped on a changeup and lined it into the left-field seats, a two-run shot that made it 3-0.

Goldschmidt, who has 32 home runs and 107 RBIs, homered in three straight games for the third time in his career.

Arizona tacked on another run in the third when J.D. Martinez drew a two-out walk on a 3-2 pitch and scored when Brandon Drury doubled off the center field wall to make it 4-0.

Herrmann led off the Arizona fourth with his ninth home run of the season, but first since July 18. Ray and Peralta followed with singles and, after Rosales hit into a double play, Pollock singled Ray home and the Diamondbacks led 6-0.

TRAINER’S ROOM

Dodgers: 1B Cody Bellinger was reinstated from the 10-day DL and back in the lineup after missing nine games with a sprained ankle. …. RHP Brandon McCarthy (finger blister) will throw a bullpen session Thursday before making a second minor league rehab start this weekend. … LHP Grant Dayton underwent Tommy John surgery on Tuesday.

UP NEXT

RHP Greinke (15-6, 3.14 ERA) is 12-1 with a 2.36 ERA in 15 home starts this season but is only 3-4 with a 4.31 ERA in nine starts against the Dodgers in his career. He’s lost his last four starts against his former team. RHP Kenta Maeda (12-5, 3.76) goes for the Dodgers after limiting the Brewers to one run in a 3-1 win in Los Angeles last Friday.


More AP baseball: https://apnews.com/tag/MLBbaseball