SAN DIEGO — The Padres’ Jarred Cosart was pitching well. Then he tried to field a high throw in Boston’s 7-2 victory over San Diego on Wednesday night.

That didn’t go so well.

“I wish I could take it back,” Cosart said. “But I can’t.”

Travis Shaw, Hanley Ramirez and Brock Holt homered and David Price threw seven solid innings to lead Boston past the San Diego, with the Red Sox moving the into first place in the AL East.

Cosart (0-3) left after 3 1/3 innings when hurting his right leg while covering first base on Jackie Bradley Jr.’s grounder. Cosart landed awkwardly after reaching for Wil Myers’ erratic throw which drew an error and led to the Red Sox rally. Cosart strained his right hamstring and groin.

“I was holding my own against one of the best pitchers in baseball, and was finally getting in a good rhythm and then like I just hit the bump in the road,” Cosart said.

“That’s the biggest downfall, I guess. It happened when it did and it happened when I think momentum was starting to swing in our favor.”

Boston’s three-run fourth inning was the difference. After Shaw’s RBI, Dustin Pedroia drove in Shaw and Chris Young with a double down the left-field line.

“He missed one spot to Travis Shaw and he made him pay,” Padres manager Andy Green said.

Shaw, inserted into the lineup for a slumping Yoan Moncada, hit his 16th homer in the second inning, a two-run shot, and added an RBI single in the fourth.

Ramirez’s homer came in the eighth off Jake Smith’s first major league pitch.

“It’s a rude greeting to your major league career,” Green said.

Holt added a pinch-hit homer in the ninth

The Red Sox took a one-game lead over the Toronto Blue Jays, who lost 2-0 to the New York Yankees. Boston, which completed interleague play with a 14-6 record, opens a three-game series in Toronto on Friday.

Price (15-8) won his season-high sixth straight start, allowing two runs and six hits. Price, who has won four of his last five road starts, struck out eight.

Three relievers finished off the Padres, with Craig Kimbrel getting the final out.

Myers’ sacrifice fly tied the game 2-2 in the third. Cosart came around after opening the inning with a single.

The Red Sox went ahead 2-1 when Shaw crushed Cosart’s 93 mph fastball 425 feet for a two-run homer. Shaw replaced Moncada, a prized Cuban prospect, at third base after Moncada struck out seven straight times.

Yangervis Solarte’s RBI double in the first scored Myers for a 1-0 lead. Myers had reached on a single.

Green said it’s likely that Cosart won’t be ready for his next start. He was moving gingerly in the clubhouse after the game.

“I felt it grab when I took off,” Cosart said. “When I came down I went straight down. We’re thinking I did it on the push off, and it probably didn’t help that I missed the bag because I was coming down thinking I was going to be on the bag and I didn’t. Out there it was really grabbing pretty good. I wanted to pitch but that wasn’t going to happen.”

TRAINERS ROOM

Red Sox: RHP Steve Wright (bursitis right shoulder) remains out and manager John Farrell said he doesn’t know an end date to the injury.

UP NEXT:

Red Sox: RHP Rick Porcello (19-3, 3.23) opens a three-game series in Toronto on Friday. Porcello has thrown eight straight quality road starts. In three starts against the Blue Jays this year he is 2-0 with a 5.21 ERA.

Padres: LHP Clayton Richard (1-3, 3.29) gets the nod as the visiting Colorado Rockies arrive on Thursday. Richard threw five innings of one-run ball on Sept. 1 against the Dodgers but didn’t factor into the win. He is 1-2 in four starts with the Padres this year.