BOSTON — It’s hard not to make comparisons between Hanley Ramirez and the great Manny Ramirez given the way the former has been swinging the bat.

Hanley, once projected to be the Red Sox’s next great hitter when he was signed as an amateur free agent in 2000, never got his chance to prove his mettle in Boston after being traded to the Florida Marlins in 2005.

Manny, on the other hand, had won a World Series ring the year prior and went on to win another with the club in 2007, cementing himself as one of the greatest hitters of his generation.

His iconic swing and wacky mannerisms earned him a place of endearment in the hearts of Red Sox fans. A sense of endearment that Hanley is finally getting the chance to earn in Boston.

“That’s a pretty lofty comparison,” Red Sox manager John Farrell said after Hanley’s two-homer, four-RBI night led Boston to a 5-4 win over the New York Yankees on Sunday night at Fenway Park.

“We’ll take the current Ramirez obviously.”

The current Ramirez has been on a Manny-like tear lately, going 9-for-16 and bashing four homers and driving in nine runs in the four-game set with the Yankees.

Ramirez launched the go-ahead solo shot clear over the Green Monster in left field in the seventh inning, two innings after his blasted a three-run Monster shot.

Ramirez has 28 homers on the year, nine in September and 20 since the All-Star break.

He also matched his career high in RBIs at 106, set in 2009 with the Florida Marlins.

“He’s locked in,” Farrell said. “He’s very dangerous right now.”

Boston (85-64) moved a season-high 21 games over .500 heading into Monday night’s game and captured its first sweep of New York (77-72) in a series of four or more games in 26 years since June 4-7, 1990.

“I think we all are (hot), the whole team,” Ramirez said. “We’ve been able to create some rallies … and continue to fight all the way to the end.”

The Red Sox moved three games ahead of the Baltimore Orioles for first place in the American League East. Meanwhile, the Yankees fell eight games behind in the division and four back of the second AL wild-card spot.

“You’re still playing the teams in front of you, some of them, so we’ve got to start over Tuesday,” New York manager Joe Girardi said.

Robby Scott earned his first career victory in 2/3 innings of relief for Boston.

Koji Uehara notched his seventh save with a scoreless ninth.

Red Sox starter Drew Pomeranz stumbled through a 3 2/3-inning no-decision, allowing four runs on seven hits and two walks with three strikeouts.

Pomeranz is 0-3 in five starts since his last win Aug. 20 at Detroit.

Gary Sanchez smashed his second home run in as many days and his 16th of the season in just 41 games, the most by a Yankees rookie since Hideki Matsui clubbed 16 in 2003.

The only Yankees rookie to hit more homers in a season was Alfonso Soriano, who hit 18 in 2001.

Tyler Clippard (1-1 in AL) took the loss after coughing up Ramirez’s homer.

Yankees starter CC Sabathia tossed four scoreless frames before surrendering three runs in the fifth and another in the second.

He gave up eight hits and walked three with five punch outs in a no-decision.

After Ramirez’s homer shaved three runs off the Red Sox’s deficit in the fifth, Jackie Bradley Jr. tied the game at 4 an inning later with his RBI single to right field.

David Ortiz was greeted with a raucous ovation when he entered as a pinch hitter for catcher Bryan Holaday the next at-bat, but he struck out swinging.

Ramirez cleared the Monster with his decisive seventh-inning blast.

Didi Gregorius drove in the game’s first run with a first-inning single.

Sanchez doubled the lead when he ripped a Pomeranz cutter off the top of the Green Monster in left for his homer with two outs in the third.

Pomeranz got into trouble in the fourth when he walked the bases loaded with nobody out.

Brett Gardner brought a run in on his fielders’ choice to second base.

Ronald Torreyes followed with a grounder to third baseman Travis Shaw, who fired to second for the force out. Mason Williams took off from third after Shaw’s throw and beat the throw at home plate.

Sabathia allowed the Red Sox to put a pair of runners in scoring position after overthrowing first baseman Billy Butler on a potential inning-ending double play in the fifth.

“It was a tough play,” Sabathia said. “I was trying to hit him on the move. I end up short arming it and it kind of sailed on me.”

One at-bat later, Ramirez unloaded on a 3-1 Sabathia slider for a homer to bring Boston within a run.