ST. PETERSBURG, Fla. — Dustin Pedroia hit his fourth career grand slam to help Rick Porcello get his major league-leading 22nd win, and the Boston Red Sox clinched a playoff berth Saturday night by beating the Tampa Bay Rays 6-4 for their 10th consecutive win.

Boston maintained a 5½-game lead over Toronto for the division title and ensured no worse than the AL’s second wild card. While the Red Sox technically have a magic number of one, the Blue Jays and Baltimore Orioles play each other three times in the season’s final week, meaning only one of them can win match Boston’s 91 wins.

Among the other wild-card contenders, only Detroit can reach 91 victories.

Pedroia stopped an 0-for-17 skid with a single in the sixth and gave Boston a 6-3 lead with a seventh-inning drive off Danny Farquhar.

Porcello (22-4) gave up three runs, eight hits and struck out nine over 61/3 innings. He just missed getting his 12th consecutive start of seven or more innings and three runs or fewer, which would have moved him past Cy Young (1904) and Pedro Martinez (2000) for the longest stretch during the same season in franchise history.

Craig Kimbrel, the fifth Boston reliever, reached 30 saves for the sixth straight season despite allowing Logan Forsythe’s solo homer in the ninth.

Brad Miller hit a two-run double in a three-run second that put Tampa Bay up 3-1 and gave him 80 RBI.

Tampa Bay threatened in the second but failed to score due to two nice defensive plays. Pedroia made a throw from just in front of the outfield grass at second base on Mikie Mahtook’s grounder to get Corey Dickerson at the plate. Third baseman Brock Holt made a solid play along the line on Alexei Ramirez’s grounder and threw him out at first to end the inning.

NOTES: Red Sox knuckleballer Steven Wright (right shoulder) isn’t ready to throw off a mound, but did throw at 120 feet on level ground for the second straight day. … Tampa Bay designated hitter Nick Franklin (left hamstring) was in the lineup for the first time since Sept. 15. He did pinch-hit twice in between. … Farrell said left-hander David Price will start Tuesday and Sunday, which lines him up for Game 2 of the AL division series. … The Rays will honor Red Sox designated hitter David Ortiz in a pregame ceremony Sunday before his final game at Tropicana Field. He will be just the fourth visiting player to be honored, joining Derek Jeter, Mariano Rivera and Cal Ripken Jr. “Whenever somebody takes their time to honor my career I always appreciate it,” Ortiz said.

MANAGER JOHN John Farrell has not ruled out injured third baseman Pablo Sandoval returning this year should an injury replacement be required.

Sandoval was not expected back until 2017 following a left shoulder injury that sent him to the disabled list after just three games in April.

“We’re staying open-minded,” Farrell said. “If something was to happen, does he make himself an option? That door has not been closed.”

Sandoval has been the designated hitter with the Red Sox’s instructional league team in Fort Myers, Florida, and is expected soon to play in the field.

Sandoval worked out with the AL East leaders Saturday, taking batting practice and doing defensive drills.