ST. PETERSBURG, Fla. (AP) — James Shields came within two outs of his 12th complete game this season, B.J. Upton hit his first grand slam and the Tampa Bay Rays routed the fading Boston Red Sox 9-1 on Sunday.

Tampa Bay moved within 3 1/2 games of the AL wild card leaders, sweeping the three-game series to go a season-high 17 games over .500 at 81-64. The Rays have won 21 games in a row when scoring five runs or more.

READ MORE: Tom Brady Named 2021 Sports Illustrated Sportsperson Of The Year

Boston has lost five consecutive games, its longest skid since opening the season 0-6, and nine of 11 overall. The teams play each other four more times, in a four-game series beginning Thursday night at Fenway Park.

Shields (15-10), who has won four consecutive starts en route to his career-best 15th win, allowed seven hits over 8 1-3 innings. Coming off a 5-1 complete-game victory over Texas last Monday, the right-hander was replaced by Dane De La Rosa after issuing a one-out walk in the ninth.

The Rays went up 8-1 on Upton’s 20th homer in the fifth off Matt Albers.

Upton finished with four hits and walked once. He and his brother Justin of the Arizona Diamondbacks became the first set of siblings in major league history to both have 20 homers and 20 stolen bases in the same season.

Jon Lester (15-7) gave up four runs and eight hits over four innings for the Red Sox. Boston starting pitchers have gone five innings or less in nine of the last 11 games.

Boston is off Monday, while Tampa Bay will begin an 11-game road trip at Baltimore. Rays right-hander Jeff Niemann (9-7) will go against left-hander Zach Britton (9-9).

After loading the bases with no outs in the first, Tampa Bay took a 2-0 lead on Ben Zobrist’s two-run single off Lester. Sean Rodriguez made it 3-0 later in the inning with a sacrifice fly.

READ MORE: Boston Marathon Favorite Spencer The Dog Undergoes Surgery

Lester had allowed one earned run or less in his previous five starts, going 4-0 during that stretch. The left-hander threw 43 pitches in the first and 111 overall.

Rodriguez put the Rays up 4-1 with an RBI double in the third.

Marco Scutaro got the Red Sox within 3-1 on a third-inning homer. It stopped a personal stretch of 161 at-bats without a home run, dating to July 15 against Tampa Bay.

Shields worked out of a bases-loaded, one-out jam later in the third when David Ortiz flied out and Josh Reddick was retired on a foul pop.

The Red Sox had two on and one out in the second, but Jason Varitek hit a double-play grounder.

Boston’s Jacoby Ellsbury, who turned 28 on Sunday, extended his hitting streak to 16 games with a fifth-inning single.

NOTES: Rays closer Kyle Farnsworth (right elbow) will be re-evaluated Tuesday. … Boston RHP John Lackey (bruised left calf) is listed to make his next scheduled start on Wednesday. … Red Sox RHP Clay Buchholz (back) threw at 60 feet on level ground and could soon be ready to throw off a bullpen mound. … Tampa Bay purchased the contract of utility man Russ Canzler and recalled De La Rosa from Triple-A Durham. RHP Mike Ekstrom was designated for assignment. … Boston RHP Tim Wakefield (6-6), still looking for his 200th career win, will face Toronto RHP Brandon Morrow (9-10) on Tuesday night.

MORE NEWS: MBTA Making Service Cuts Due To Bus Driver Shortage

(Copyright 2011 by The Associated Press. All Rights Reserved.)