BOSTON — Mike Napoli doubled in Dustin Pedroia in the bottom of the ninth inning to give the Boston red Sox a 3-2 win over the Tampa Bay Rays Monday afternoon at Fenway Park.

Andrew Bailey, who blew the save and allowed a Rays run in the top of the ninth, picked up the win.

Ryan Dempster, the former Portland Sea Dogs right-hander who joined the Red Sox as a free agent this year, pitched well enough to win, but didn’t. He allowed only two hits and one run over seven innings.

Before Napoli’s hit, a Jacoby Ellsbury triple and Jarrod Saltalamacchia home run powered the Red Sox in their annual 11 a.m. game on Patriots Day. Boston continues to lead the American League East Division with an 8-4 record. The Rays dropped to 4-8.

Ellsbury led off the bottom of the first with a triple to deep center field. He scored on Shane Victorino’s ground-out.

Dempster allowed only one hit until Evan Longoria swatted a fastball over the left field Monster in the fourth inning, tying the game 1-1. Saltalamacchia gave Boston the lead again in the fifth, connecting on a 0-2 fastball from Jeremy Hellickson (0-2), launching into the Rays bullpen in right field.

Dempster got into trouble in the sixth after two walks. Longoria came up with two outs and runners on first and third. On a full count, Longoria hit a ground ball that looked headed for center field. Shortstop Stephen Drew made a diving stop, popped up and threw Longoria out.

Dempster pitched a 1-2-3 seventh to finish his outing. Koji Uehara pitched a perfect eighth inning.

Bailey, who is filling in for closer Joel Hanrahan (sore hamstring), allowed a lead-off single to Desmond Jennings in the ninth. Jennings stole second and scored on Ben Zobrist’s single to left, tying the game 2-2.

Pedroia walked with one out. Napoli then swatted a high line drive off the left field wall. Pedroia raced around to score.

The Red Sox play again Tuesday night in Cleveland (facing former Sox manager Terry Francona). Felix Doubront (0-0) gets the ball for Boston, against Ubaldo Jimenez (0-1).