SAN FRANCISCO — Robbie Ray won his fifth consecutive start and A.J. Pollack hit a two-run double as the Arizona Diamondbacks defeated the San Francisco Giants 3-2 on Friday night.

Ray (14-5) struck out 10 and gave up two runs (one earned), six hits and no walks as the Diamondbacks won for the 19th time in 24 games and for the eighth time in a row on the road.

Ray has a 1.39 ERA in his past five starts since coming off the disabled list with a concussion after getting hit by a line drive on July 28.

Arizona reduced its magic number for clinching its first postseason berth since 2011 to seven. The Diamondbacks trailed 2-1 when Pollack doubled in two runs off Giants starter Jeff Samardzija (9-14) in the seventh inning.

Daniel Descalso started the rally with a two-out single that snapped a streak of 14 consecutive batters Samardzija had retired.

Samardzija gave up three runs, six hits and no walks in eight innings.

It marked just the eighth time this season that both teams allowed no walks.

Fernando Rodney pitched a scoreless ninth for his 37th save.

CLOSE CALL

Ray was nearly hit with a line drive when Kelby Tomlinson singled up the middle in the third inning. Ray was on the DL for nearly a month after being hit in the head with a line drive on July 28.

GIANT CLAIM

The Giants claimed INF Engelb Vielma from the Minnesota Twins. They transferred INF/OF Michael Morse to the 60-day disabled list to make room for the 23-year-old defensive standout on their 40-man roster.

TRAINER’S ROOM

Diamondbacks: OF J. D. Martinez was a late lineup scratch with neck stiffness. Martinez is batting .451 (23 for 51) with 10 homers and 20 RBIs over his last 12 games. ... C Jeff Mathis (fractured right hand) is with the team and is ramping up hand-strengthening exercises, manager Torey Lovullo said. Mathis will meet with surgeon Dr. Don Sheridan next week when the team returns to Arizona. He’s been on the DL since Aug. 22.

Giants: Closer Mark Melancon is back with the team and has started rehabbing after undergoing pronator surgery on his right forearm earlier this week. There were no complications with the procedure, manager Bruce Bochy said. … OF Gorkys Hernandez went into Friday’s game as a defensive substitute in center field despite suffering a left wrist sprain.