BOSTON — Rick Porcello discovered his groove and the Boston Red Sox backed him with 21 hits in a 12-5 win over the Texas Rangers Monday afternoon before 36,253 at Fenway Park.

Porcello gave up four runs in the first inning, but settled down for five scoreless innings.

The Red Sox got a run back in the first and then scored four in the third inning, capped by Brock Holt’s two-run homer into the Red Sox bullpen, giving Boston a 5-4 lead.

The Red Sox kept on hitting and Dustin Pedroia’s seventh-inning home run over the Green Monster made it 9-4. Travis Shaw (3 for 5) and Mookie Betts both homered in the eighth.

Sandy Leon went 4 for 5 with hit three doubles. David Ortiz and Hanley Ramirez both added two doubles.

The Sox had 13 extra-base hits.

“We just put pressure on them and continued to have good at-bats,” Betts said.

Boston (45-37) won its second game in a row and moved to within 2½ games of the first-place Baltimore Orioles in the American League East. The Orioles were playing a late game Monday night at the Los Angeles Dodgers.

Texas (52-32) leads the West by 71/2 games.

Porcello (10-2) needed 32 pitches in the first inning, allowing five hits and four runs (three earned). He gave up seven more hits in the next five innings, but kept the Rangers scoreless.

Matt Barnes pitched a scoreless seventh. Koji Uehara gave up a solo home run to Rougned Odor in the eighth. Robbie Ross pitched the last 12/3 innings.

Not only did Holt homer but, as Boston’s left fielder, he preserved the lead by throwing out Shin-Soo Choo, trying to score from second base on a single in the fourth. Holt missed 37 games because of a concussion – Boston went 17-20 in those games. Since Holt has come back, Boston is 3-0 in the games he’s played, and he’s 5 for 13.

“His timing to the plate has been pretty spot-on,” Manager John Farrell said. “He’s a heady player. And usually he’s involved in a play that will be meaningful.”

Leon improved his average to .500 (20 for 40) and has moved into the No. 1 catcher’s spot.

“I’m just seeing the ball really well,” Leon said. “This is an opportunity. I hope I can keep doing it.”

NOTES: After the game, Farrell announced that catcher Ryan Hanigan would be activated from the disabled list and Christian Vazquez was headed to Triple-A Pawtucket … Farrell also named Sean O’Sullivan the starter for Friday’s game against Tampa Bay and said Clay Buchholz would go to the bullpen.