Christian Villanueva had a walk-off pinch-hit single in the ninth inning, and the San Diego Padres ended a five-game skid with a 7-6 win over the Arizona Diamondbacks on Saturday night.

Travis Jankowski led off the ninth with a walk against Andrew Chafin (1-4) and advanced to second on a groundout by Eric Hosmer. Yoshihisa Hirano replaced Chafin and intentionally walked Hunter Renfroe.

More Images
San Diego Padres' Christian Villanueva heads to first with a walk-off single against the Arizona Diamondbacks during a baseball game in San Diego, Saturday, Aug. 18, 2018. The Padres won 7-6. (AP PhotoKyusung Gong)

Christian Villanueva had a walk-off pinch-hit single in the ninth inning, and the San Diego Padres ended a five-game skid with a 7-6 win over the Arizona Diamondbacks on Saturday night.

Arizona Diamondbacks' A.J. Pollock slides to score during the seventh inning of the team's baseball game against the San Diego Padres in San Diego, Saturday, Aug. 18, 2018. (AP PhotoKyusung Gong)

Paul Goldschmidt had four hits and drove in four runs while tying a Diamondbacks record by reaching base safely in nine straight plate appearances. Goldschmidt also extended his hitting streak to 11 games.

San Diego Padres' Christian Villanueva hits a walk-off single against the Arizona Diamondbacks during a baseball game in San Diego, Saturday, Aug. 18, 2018. The Padres won 7-6. (AP PhotoKyusung Gong)

San Diego evened the score in the fourth with a three-run inning. Goldschmidt doubled home Escobar in the fifth to build a 5-3 lead.

San Diego Padres' Eric Hosmer celebrates his RBI double during the fifth inning of a baseball game against the Arizona Diamondbacks in San Diego, Saturday, Aug. 18, 2018. (AP PhotoKyusung Gong)

Both starters struggled. Arizona's Zack Godley allowed six runs on eight hits in five innings. Clayton Richard went five for the Padres, allowing five runs on nine hits.

Arizona Diamondbacks' Jon Jay (9) is welcomed in the dugout after scoring on a sacrifice fly by A.J. Pollock during the fifth inning of a baseball game against the San Diego Padres in San Diego, Saturday, Aug. 18, 2018. (AP PhotoKyusung Gong)

Padres: RHP Brett Kennedy (0-2, 11.00) will make his third career start. In his previous outing, he allowed five runs in five innings against the Los Angeles Angels.

San Diego Padres' Freddy Galvis hits a two-run single during the fourth inning of a baseball game against the Arizona Diamondbacks in San Diego, Saturday, Aug. 18, 2018. (AP PhotoKyusung Gong)

San Diego Padres' Freddy Galvis hits a two-run single during the fourth inning of a baseball game against the Arizona Diamondbacks in San Diego, Saturday, Aug. 18, 2018. (AP PhotoKyusung Gong)

Arizona Diamondbacks starting pitcher Zack Godley delivers a pitch during the third inning of a baseball game against the San Diego Padres in San Diego, Saturday, Aug. 18, 2018. (AP PhotoKyusung Gong)

Arizona Diamondbacks starting pitcher Zack Godley delivers a pitch during the third inning of a baseball game against the San Diego Padres in San Diego, Saturday, Aug. 18, 2018. (AP PhotoKyusung Gong)

San Diego Padres starting pitcher Clayton Richard delivers a pitch during the third inning of a baseball game against the Arizona Diamondbacks in San Diego, Saturday, Aug. 18, 2018. (AP PhotoKyusung Gong)

San Diego Padres starting pitcher Clayton Richard delivers a pitch during the third inning of a baseball game against the Arizona Diamondbacks in San Diego, Saturday, Aug. 18, 2018. (AP PhotoKyusung Gong)

Villanueva hit for Craig Stammen (6-2) and drove a 2-2 pitch into left field to score Jankowski and give San Diego its first win against Arizona at Petco Park this season. Stammen worked two scoreless innings.

San Diego Padres' Christian Villanueva heads to first with a walk-off single against the Arizona Diamondbacks during a baseball game in San Diego, Saturday, Aug. 18, 2018. The Padres won 7-6. (AP PhotoKyusung Gong)

San Diego Padres' Christian Villanueva heads to first with a walk-off single against the Arizona Diamondbacks during a baseball game in San Diego, Saturday, Aug. 18, 2018. The Padres won 7-6. (AP PhotoKyusung Gong)

Paul Goldschmidt had four hits and drove in four runs while tying a Diamondbacks record by reaching base safely in nine straight plate appearances. Goldschmidt also extended his hitting streak to 11 games.

The Diamondbacks' three-game winning streak ended, and their NL West lead over the Colorado Rockies fell to one-half game.

Arizona built an early lead thanks to doubles by A.J. Pollack and Eduardo Escobar. Goldschmidt singled to give the Diamondbacks a 2-0 advantage, a familiar position for a team that leads the majors in first-inning runs with 107.

Arizona Diamondbacks' A.J. Pollock slides to score during the seventh inning of the team's baseball game against the San Diego Padres in San Diego, Saturday, Aug. 18, 2018. (AP PhotoKyusung Gong)

Arizona Diamondbacks' A.J. Pollock slides to score during the seventh inning of the team's baseball game against the San Diego Padres in San Diego, Saturday, Aug. 18, 2018. (AP PhotoKyusung Gong)

San Diego evened the score in the fourth with a three-run inning. Goldschmidt doubled home Escobar in the fifth to build a 5-3 lead.

The Padres answered with three more runs in the fifth. Cory Spangenberg's single gave San Diego its first lead of the series at 6-5.

Goldschmidt struck again in the seventh after another double by Pollack, singling against Phil Maton to tie the game.

San Diego Padres' Christian Villanueva hits a walk-off single against the Arizona Diamondbacks during a baseball game in San Diego, Saturday, Aug. 18, 2018. The Padres won 7-6. (AP PhotoKyusung Gong)

San Diego Padres' Christian Villanueva hits a walk-off single against the Arizona Diamondbacks during a baseball game in San Diego, Saturday, Aug. 18, 2018. The Padres won 7-6. (AP PhotoKyusung Gong)

Both starters struggled. Arizona's Zack Godley allowed six runs on eight hits in five innings. Clayton Richard went five for the Padres, allowing five runs on nine hits.

UP NEXT

Diamondbacks: RHP Zack Grienke (12-8, 3.00 ERA) looks to continue his dominance of the Padres in the finale of the four-game series. Grienke is 11-2 with a 2.10 ERA in his career against San Diego.

San Diego Padres' Eric Hosmer celebrates his RBI double during the fifth inning of a baseball game against the Arizona Diamondbacks in San Diego, Saturday, Aug. 18, 2018. (AP PhotoKyusung Gong)

San Diego Padres' Eric Hosmer celebrates his RBI double during the fifth inning of a baseball game against the Arizona Diamondbacks in San Diego, Saturday, Aug. 18, 2018. (AP PhotoKyusung Gong)

Padres: RHP Brett Kennedy (0-2, 11.00) will make his third career start. In his previous outing, he allowed five runs in five innings against the Los Angeles Angels.

More AP MLB: https://apnews.com/tag/MLB and https://twitter.com/AP_Sports

Arizona Diamondbacks' Jon Jay (9) is welcomed in the dugout after scoring on a sacrifice fly by A.J. Pollock during the fifth inning of a baseball game against the San Diego Padres in San Diego, Saturday, Aug. 18, 2018. (AP PhotoKyusung Gong)

Arizona Diamondbacks' Jon Jay (9) is welcomed in the dugout after scoring on a sacrifice fly by A.J. Pollock during the fifth inning of a baseball game against the San Diego Padres in San Diego, Saturday, Aug. 18, 2018. (AP PhotoKyusung Gong)

San Diego Padres' Freddy Galvis hits a two-run single during the fourth inning of a baseball game against the Arizona Diamondbacks in San Diego, Saturday, Aug. 18, 2018. (AP PhotoKyusung Gong)

San Diego Padres' Freddy Galvis hits a two-run single during the fourth inning of a baseball game against the Arizona Diamondbacks in San Diego, Saturday, Aug. 18, 2018. (AP PhotoKyusung Gong)

Arizona Diamondbacks starting pitcher Zack Godley delivers a pitch during the third inning of a baseball game against the San Diego Padres in San Diego, Saturday, Aug. 18, 2018. (AP PhotoKyusung Gong)

Arizona Diamondbacks starting pitcher Zack Godley delivers a pitch during the third inning of a baseball game against the San Diego Padres in San Diego, Saturday, Aug. 18, 2018. (AP PhotoKyusung Gong)

San Diego Padres starting pitcher Clayton Richard delivers a pitch during the third inning of a baseball game against the Arizona Diamondbacks in San Diego, Saturday, Aug. 18, 2018. (AP PhotoKyusung Gong)

San Diego Padres starting pitcher Clayton Richard delivers a pitch during the third inning of a baseball game against the Arizona Diamondbacks in San Diego, Saturday, Aug. 18, 2018. (AP PhotoKyusung Gong)