ARLINGTON, Texas — Mookie Betts hit a two-run homer in the ninth inning and Dustin Pedroia scored the tiebreaking run on a wild pitch as the Boston Red Sox rallied for an 8-7 win over the Texas Rangers on Friday night.

Betts’ 16th homer came with two outs off Matt Bush (2-1), who had just taken over after pinch-hitter Sandy Leon hit an RBI double on the 11th pitch of his at-bat against Jake Diekman. Pedroia then walked, went to third on Xander Bogaerts’ single and came home on the wild pitch.

Heath Hembree (4-0) worked a scoreless eighth before Koji Uehara struck out the side in the ninth for his second save.

The Red Sox trailed 6-0 early after starter David Price allowed 12 hits in only 21/3 innings.

Hanley Ramirez and Jackie Bradley both hit two-run homers off Texas starter Nick Martinez, who went six innings before Tony Barnette threw two scoreless innings.

After a day off Thursday, the Rangers went with Diekman in the ninth instead of closer Sam Dyson. Diekman had allowed a three-run homer Wednesday against Cincinnati, snapping his scoreless streak of 142/3 innings before Dyson pitched the ninth for his 15th save – and 13th in a row since becoming the Texas closer May 18.

Diekman got two outs after a leadoff walk to Bradley. The big lefty was removed after the long at-bat by Leon, and then Betts hit a 1-1 pitch from the hard-throwing Bush.

Shin-Soo Choo hit a leadoff homer against Price, and the first four Texas batters reached, including a two-run single on the first of Elvis Andrus’ three hits.

Ian Desmond also had three hits for Texas, including an RBI single in the second inning after Bobby Wilson snapped an 0-for-15 slump with a double. An inning later, Wilson hit a two-run single to chase Price with the Rangers up 6-0.

Price’s ERA in seven regular-season starts at Texas is now 7.68 – by far his worst at any opposing stadium.

He had gone at least eight innings in his previous three starts, and had a 2.47 ERA over his last eight starts for the Red Sox. The left-hander has given up more hits only once in his 234 career games.