PHOENIX (AP) - Paul Goldschmidt homered for the third straight game, Robbie Ray fanned 10 in 6 2/3 innings and the Arizona 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.

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.

Ray allowed four hits, walked two and hit a batter. The left-hander topped 10 strikeouts for the seventh time this season. Fernando Rodney pitched a perfect ninth for his second save in as many 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.