Updated

Brett Gardner stroked a go-ahead, three-run triple as part of a four-run sixth inning that vaulted the New York Yankees to a 9-6 victory over the Boston Red Sox Sunday in the rubber match of a three- game set at Fenway Park.

Alex Rodriguez started the sixth with a deep homer to straightaway center field, exacting a measure of revenge against Boston starter Ryan Dempster (6-9), who plunked Rodriguez in his first plate appearance, resulting in both benches clearing briefly and New York manager Joe Girardi being ejected from the game after both teams received warnings.

"It was awesome. I was pretty excited," Rodriguez said of his blast. "It was the ultimate payback."

The Yankees third baseman finished 3-for-4 with two RBI and two runs scored, while Eduardo Nunez collected three hits and an RBI for New York, which has won six of its last eight games.

New York starter CC Sabathia (11-10) earned the victory, despite not having his best stuff, as the left-hander gave up six runs on seven hits and five walks over 5 1/3 innings.

Mariano Rivera, who had blown his last three save opportunities, worked around a two-out single and a walk in the ninth to secure his 36th save of the season.

Will Middlebrooks smacked a solo shot and Jarrod Saltalamacchia added two hits, an RBI, and a run scored for the Red Sox, who have lost seven of their last 10 games to see their lead over Tampa Bay atop the AL East shrink to one game.

Dempster was tagged for seven runs on nine hits over 5 1/3 frames to remain winless (0-6) in eight career starts against the Yankees.

Boston pushed a pair of runs across in the first before things got chippy in the second, as Dempster fired his first pitch of the frame behind the legs of Rodriguez, arousing a roar of cheers from the Boston faithful.

Dempster's next two offerings missed inside before the right-hander drilled Rodriguez in the left arm with a fastball.

"I was just trying to pitch him inside," Dempster said of his approach against Rodriguez.

Home plate umpire Brian O'Nora immediately warned both benches, prompting Girardi to come flying out of the Yankee dugout before being ejected.

"Everyone knows it was intentional and I don't understand why (Dempster) is left in the game," Girardi remarked. "Brian and I have a long history together and I respect him but that was wrong."

Both benches cleared briefly and when the dust finally settled and play resumed, Curtis Granderson ripped a double down the right-field line.

Nunez followed with a single to left-center to score Rodriguez before Lyle Overbay's sacrifice fly to left plated Granderson to tie the game at 2-2.

Rodriguez put the Yankees ahead in his next turn at-bat with an RBI groundout in the third, but David Ortiz responded with a run-scoring groundout of his own in the home half to knot the game at 3-3.

Boston regained the lead in the fourth, as Saltalamacchia smacked a leadoff double off the Green Monster, moved to third on a sacrifice bunt and scored on Stephen Drew's sac fly to left to make it 4-3.

Middlebrooks doubled the lead two pitches later, launching an 0-1 fastball into the Boston bullpen in right center for a 5-3 cushion.

Daniel Nava's bases-loaded walk in the fifth made it a 6-3 margin, but Rodriguez led off the sixth with a towering drive into straightaway center field.

After Granderson grounded out, Nunez and Overbay smacked consecutive singles before Chris Stewart walked to load the bases and end Dempster's outing, as Drake Britton was called in from the bullpen.

Gardner greeted Britton with a bases-clearing triple into right-center field to give the Yankees a 7-6 lead.

Drew cut down Gardner at the plate when Ichiro Suzuki followed with a grounder to short, but the Yankees got the run back in the seventh, as Granderson reached on a fielder's choice before swiping second.

After Jayson Nix fanned for the second out, Franklin Morales took over on the mound to face pinch-hitter Mark Reynolds, who ripped a single to center to score Granderson for an 8-6 advantage.

New York added an insurance run in the ninth. Nix was plunked and he moved to second on a wild pitch before stealing third two batters later and scoring on Stewart's single through the left side of the infield.

Rivera retired the first two Red Sox in the home half of the ninth, but Ortiz came through with a single before Jonny Gomes worked a walk to bring the tying run to the plate.

However, Rivera got Saltalamacchia to lineout sharply to left to end the contest.

Game Notes

Nava started at first base and has reached base safely in a career-high 30 straight starts ... Boston had won six straight games started by Dempster ... Boston has lost three straight series for the first time since a three-series slide from May 3-12 ... Sabathia improved to 4-4 in 12 career starts at Fenway Park ... New York finished 5-for-21 with runners in scoring position and left 13 men on base ... Nunez left the game in the sixth inning with a left hamstring strain.