BOSTON — Hanley Ramirez couldn’t hold back a smile when asked if he’s hot yet.

Ramirez homered twice and drove in four runs to rally the Boston Red Sox over New York 5-4 on Sunday night, completing a four-game sweep that severely diminished the Yankees’ chances of winning the AL East.

“I think we all are, our whole team,” Ramirez said. “We’ve been able to create some rallies when we needed to and continued to fight.”

Jackie Bradley Jr. had a tying RBI single for the East-leading Red Sox, who overcame a rough start by Drew Pomeranz to post their ninth win in 12 games. Boston remained three games ahead of second-place Baltimore, which beat Tampa Bay 2-1 on Sunday.

The Red Sox open a 10-game trip at Baltimore with the first of four games on Monday night.

Gary Sanchez belted his 16th homer since Aug. 3 for the Yankees, who dropped eight back in the division and remained four behind Toronto for the second wild-card spot.

The Yankees were without second baseman Starlin Castro and center fielder Jacoby Ellsbury, who were both injured Saturday. Castro strained his right hamstring running out a double and Ellsbury bruised his right knee sliding into a bullpen wall trying to make a catch.

The Red Sox overcame deficits three times in the series, including the opener, when they scored five in the ninth and Ramirez hit a game-ending three-run homer.

“This team’s amazing,” Pomeranz said. “It seems like we’re never out of reach. It’s fun to watch.”

This time, Ramirez hit a fly ball that soared over the Green Monster off Tyler Clippard (1-1) for a 5-4 lead in the seventh. It was his 12th homer in 21 games.

“We could’ve won all four of these games here,” Yankees manager Joe Girardi said. “We just weren’t able to shut them down. They’re a very good offense and we understand that.”

Robby Scott (1-0) retired the only two batters he faced for his first major league victory. Koji Uehara got the final three outs for his seventh save.

“I couldn’t be more excited to be a part of it,” said Scott, who played six seasons in Boston’s farm system before he was called up to the majors.

New York scored single runs in the first and third before chasing Pomeranz with two in the fourth.

But the Red Sox sliced it to 4-3 when Ramirez hit a line drive off the base of a light stanchion above the Monster after CC Sabathia threw widely to first on what would have been an easy inning-ending double play.

Ramirez said his teammates were saying “make him pay” before he walked to the plate.

Sabathia said he just tried to be too careful with the throw.

“It’s tough. This time of year it’s just one play that always makes the difference right now,” Sabathia said. “It just so happened to bite me.”

Sabathia gave up four runs and eight hits in five-plus innings.

Didi Gregorius drove in the Yankees’ first run with an RBI double before Sanchez hit a shot that caromed off a billboard above the left-field seats.

TRAINER’S ROOM

Yankees: 3B Chase Headley was also out of the lineup after his back stiffened up Saturday.

Red Sox: Red Sox slugger David Ortiz struck out as a pinch hitter, getting most of the night off after running the bases a lot the first three games.

MOOKIE MAGIC

RF Mookie Betts made two diving catches in right, the second against Brett Gardner leading off the ninth that brought chants of “MVP! MVP!”

TRENDING DOWN

Pomeranz had his second straight rough start, giving up four runs in 3 2/3 innings. He lasted just two innings in his previous one, allowing five runs in a loss to the Orioles on Tuesday.

UP NEXT

Yankees: New York is off Monday. RHP Michael Pineda (6-11, 4.94 ERA) is set to start against Tampa Bay LHP Drew Smyly (7-11, 4.98) in the opener of a three-game series on the road Tuesday.

Red Sox: RHP Rick Porcello (20-4, 3.12) faces Baltimore RHP Dylan Bundy (9-5, 3.88) on Monday.