Josh Collmenter (5-5) intentionally walked Nick Hundley to load the bases, and Amarista slapped a single through a drawn-in infield.

Arizona’s Trevor Cahill, who had won five straight starts, worked 6 2-3 innings, allowing two runs and five hits.

Padres starter Robbie Erlin allowed two runs, three hits and a walk, while striking out seven in seven innings.

The Diamondbacks tied the score in the fourth inning when Martin Prado hit his 14th homer of season. Paul Goldschmidt led off the inning with a single.

After the homer, Padres pitchers retired 24 straight batters.

Brewers 4, Mets 2

NEW YORK (AP) — Scooter Gennett capped a four-run second inning with a two-run single and Milwaukee overcame some wild pitching that included the beaning of David Wright.

Wright was hit in the helmet by a pitch from Johnny Hellweg with two outs in the third inning. The All-Star third baseman went down to his hands and knees but he was able to walk off the field unassisted. The Mets said he was removed as a precaution.

Hellweg hit Lucas Duda with the next pitch — in the back of the leg — and then loaded the bases with a four-pitch walk. But the Mets could not take advantage.

Hellweg failed to make it to the fifth despite leading 4-1. He gave up a run and two hits, walked four, hit two batters and threw a wild pitch. Alfredo Figaro (3-3) took over.

Dillon Gee (12-11) entered with a 2.57 ERA in his last 21 starts, and, except for an unfortunate third inning, he shut down the short-handed Brewers for six innings.

Jim Henderson gave up a homer, affirmed by video review, to pinch-hitter Josh Satin before striking out three for his 27th save.

Giants 3, Dodgers 2

SAN FRANCISCO (AP) — Angel Pagan hit a tiebreaking home run leading off the eighth inning to give San Francisco a win in what might have been Tim Lincecum’s final outing with the club.

Pagan’s fifth home run in an injury-shortened season was surrendered by losing pitcher Paco Rodriguez (3-3).

Lincecum struck out Yasiel Puig three times among his six Ks but missed a win against the NL West champion Dodgers. Santiago Casilla (7-2) earned the victory with a 1-2-3 eighth, while Sergio Romo pitched the ninth for his 38th save.

Lincecum is wrapping up a $40.5 million, two-year contract that paid him $22 million this season. The 29-year-old right-hander allowed two runs and three hits in seven impressive innings.

Dodgers starter Edinson Volquez’s winless stretch reached seven starts since he beat the Mets on Aug. 17. He didn’t beat the Giants in five tries this year.

The Giants took the season series with their rivals 11-8, earning just their third series win at home in the second half in 13 tries.

Indians 6, Twins 5

MINNEAPOLIS (AP) — Reliever Joe Smith struck out pinch-hitter Oswaldo Arcia to end a ninth-inning rally and Cleveland won its seventh straight game, holding off Minnesota to keep pace in the AL wild-card race.

The Twins scored four runs in the ninth and had runners on first and second before Smith got the final out.

Cleveland leads Texas by one game for the second wild-card spot. Each team has three games left in the regular season. Tampa Bay is on top in the chase, one game ahead of the Indians.

Yan Gomes hit a towering two-run homer and Michael Brantley added three hits and two RBIs from the leadoff spot.

Bryan Shaw (7-3) picked up the victory in relief of Zach McAllister by getting five key outs over the fifth and sixth innings.