LaMonte Wade Jr. hit a game-winning sacrifice fly in the bottom of the 10th inning and the San Francisco Giants rallied past the Cleveland Guardians 6-5 on Wednesday in the rubber match of a three-game series.

Xzavion Curry (3-4) walked a pair to load the bases with no outs. Wade hit a fly ball to left and Patrick Bailey beat a strong throw from left fielder Steven Kwan, sliding under Bo Naylor’s tag at the plate. The call was upheld upon video review.

J.D. Davis tied the game in the eighth with a towering three-run homer to left.

Camilo Doval (6-4) pitched 1 1/3 scoreless innings to earn his first win since Aug. 20.

José Ramírez hit his 215th career home run, tying Larry Doby for seventh in Guardians history.

Josh Naylor added an RBI single, as every Cleveland starter had at least one hit.

Luis Matos and Wilmer Flores had RBI singles for the Giants (75-71), who moved within one game of Arizona for the final NL wild card spot. The Diamondbacks were scheduled to play at the New York Mets on Wednesday night.

Cleveland built a 4-0 lead in the first inning on Ramirez’s two-run homer and a throwing error by third baseman Casey Schmitt that led to two more runs.

Matos cut the lead to 4-1 with an RBI single in the bottom of the first.

Guardians rookie Logan Allen allowed one run and five hits in five innings. The left-hander struck out five and walked three. Fellow rookie southpaw Kyle Harrison was charged with five runs, three earned, in four innings.

Next for the Guardians: RHP Lucas Giolito (7-13, 4.89 ERA) opens a three-game home series against Texas on Friday. Giolito is 0-2 in two starts with Cleveland, allowing 13 earned runs in 10 innings. The Rangers hadn’t announced a starter.