The Pittsburgh Pirates got a lucky break when Boston pinch-runner Jemile Weeks was hit by a batted ball in the ninth inning, beating the Red Sox 3-2 on Thursday night to keep pace in the NL pennant race.

The Pirates won their fourth in a row. They began the day 2 1/2 games ahead of Milwaukee for the second wild-card spot, and host the Brewers in a three-game series beginning Friday night.

Down 3-2, the Red Sox put runners at the corners with no outs in the ninth against Mark Melancon. Will Middlebrooks then hit a chopper down the line and ball struck the back of Weeks’ left leg as he made a dive back to third.

Weeks was called out, and Melancon retired the last two batters for his 30th save in 34 opportunities.

Gerrit Cole (10-5) allowed two runs in seven-plus innings, striking out seven and walking none. He won his season-best third straight start.

The second-year righty improved 7-1 in nine career September starts.

Starling Marte hit his 13th homer, connecting off Brandon Workman (1-10) in the fifth for a 3-1 lead. Workman lost his 10th straight decision.

Boston had closed to 3-2 in the eighth on Xander Bogaerts’ sacrifice fly, but lost for the eighth time in its last 11 games. Cole was lifted after giving up back-to-back singles to Christian Vazquez and Garin Cecchini to start the inning.

TRAINER’S ROOM

Red Sox: INF-OF Brock Holt, who has not played since Sept. 5 because of a concussion, was cleared to resume baseball activities Thursday after being examined by Pittsburgh-based head trauma specialist Micky Collins.

Pirates: SS Jordy Mercer was back in the lineup after missing two games with a lower back strain.

UP NEXT

Red Sox: RHP Allen Webster (4-3, 6.02) will start Friday night in the opener of a three-game series at Baltimore, facing RHP Kevin Gausman (7-7, 3.57).

Pirates: LHP Jeff Locke (7-5, 3.66) will face the Brewers’ Yovani Gallardo (8-10, 3.59) in the series opener.

BIG PAPI RETURNS

Boston designated hitter David Ortiz returned to the team and started at first base after missing the first two games of the series because of a family emergency. Ortiz was forced to play in the field because the DH rule is not in effect in interleague games at NL parks. He went 0 for 4 and struck out twice.

Join our Newsletter for the latest news right to your inbox