BOSTON — Melky Cabrera and Brett Lawrie homered in the eighth inning to give the White Sox an 8-6 win over the Red Sox on Wednesday, Chicago’s third win over Boston in as many nights.

Cabrera, who doubled home a first-inning run and added an RBI single on his fourth hit of the game in the ninth, connected on a two-run shot to tie the game with out in the eighth against reliever Koji Uehara. One out later, Lawrie connected off Uehara (2-3) as the White Sox (36-36) rallied to get back to .500.

Chicago will go for the sweep in a Thursday matinee against Boston (39-32).

Hanley Ramirez, dropped to seventh in Boston’s batting order, snapped a 4-4 tie with a solo homer in the sixth, and Xander Bogaerts drove in his third run of the game later in the inning.

Bogaerts came close to re-tying the game with two out in the eighth, hitting the ball near or at the red line atop the Green Monster. The ball was touched by a fan leaning out and ruled a double and in play before it was finally called a ground-rule double after a crew-chief review. Chris Young then just missed a three-run homer down the left field line. The Red Sox challenged the foul-ball ruling, which stood. Young struck out.

White Sox reliever Dan Jennings (3-1) pitched 1 1/3 scoreless innings for the win. With David Robertson unavailable after working three consecutive days, Zach Duke worked the ninth for his first save, the third of his 12-year career. Duke was the winner Monday after pitching out of a based-loaded, no-out, ninth-inning jam that he inherited.

Ramirez, who reached Chicago starter Jose Quintana for his second homer since May 10, had been hitting fifth or fourth.

His shot handed another lead to Eduardo Rodriguez, who had just given up a game-tying two-run homer to Todd Frazier (his 21st) in the top of the inning. Rodriguez, who had allowed 18 hits and 14 earned runs in 14 2/3 innings over his previous three starts, left after six innings, having yielded four hits and four runs (three earned).

Quintana, who hasn’t won since May 8 (0-6 in eight starts), has been a victim of non-support, but his teammates bailed him out in this one. He walked a career-high six while allowing six runs on eight hits in 5 1/3 innings.

Boston’s four-run outburst in the third inning matched the team’s run total from the previous three games.

Red Sox third baseman Travis Shaw left the game with a right shin contusion after three innings.

Shaw fouled a ball off what appeared to be his right ankle Tuesday night. He finished that game, but apparently was still feeling the effects on Wednesday. The injury puts his streak of 125 straight games in jeopardy — the longest Red Sox run since Dustin Pedroia played in 148 straight in 2011-12.

Quintana hadn’t walked a left-handed batter in 75 plate appearances and just one for the season, walked two in a row in the second inning. He struck out Hanley Ramirez and thought he had Shaw fanned — catcher Dioner Navarro taking two steps toward the dugout — before Shaw singled. But David Ortiz was easily thrown out at the plate by center fielder Adam Eaton.

Quintana wasn’t as lucky in the third when a walk and two singles loaded the bases. Bogaerts singled home a pair with a shot off the left field wall and David Ortiz and Jackie Bradley Jr. also singled in runs.

With one out in the fourth, Sandy Leon drew his second straight walk and rode to third on Mookie Betts’ long double. But Leon was picked off third by Navarro to help kill that threat.

NOTES: Boston LF Brock Holt took a scheduled night off after playing two rehab games for Triple-A Pawtucket, but Farrell said Holt is still dealing with concussion symptoms. … Boston C Ryan Hanigan (neck strain) hopes to start a rehab assignment Thursday. … Chicago RHP James Shields has been ripped for 31 earned runs and 32 hits — including seven homers — in his last four starts, three with his new team. Shields faces Boston RH Rick Porcello in the series finale, a Thursday matinee. Shields is 9-13 lifetime against the Red Sox, including 2-9 at Fenway Park. … Chicago’s Melky Cabrera is 14-for-25 lifetime against Porcello and 10-8 with a 4.09 ERA against the White Sox. … Wednesday night was Celtics Night at Fenway, with former greats John Havlicek and Tom Sanders and ex-GM Jan Volk on hand. … The White Sox claimed RHP Juan Minaya off waivers from the Houston Astros and sent him to Triple-A Charlotte.