ST. PETERSBURG, Fla. — Shane Victorino’s infield single snapped a seventh-inning tie and journeyman Craig Breslow gave Boston a huge boost out of the bullpen, sending the Red Sox into the AL championship series with a 3-1 victory over the Tampa Bay Rays on Tuesday night.

Koji Uehara got the final four outs — one night after giving up a game-winning homer — and the Red Sox rebounded to take the best-of-five playoff 3-1.

Back in the ALCS for the first time in five years, they’ll open at home Saturday against the Athletics or Tigers. Oakland hosts Detroit in a decisive Game 5 on Thursday.

Both managers mixed and matched all night in a tense game that felt more like a chess match.

Desperately trying to avoid elimination, Rays skipper Joe Maddon used nine pitchers and had ace David Price warming up for a possible 10th inning.

Breslow relieved Boston starter Jake Peavy in the sixth and struck out his first four batters — all of them in the middle of Tampa Bay’s lineup.

The 33-year-old lefty from Yale has pitched for six teams in eight big league seasons, including two stints with the Red Sox.

The highest-scoring team in the majors this season, Boston scratched out three runs on six singles in a game that featured only one extra-base hit.

Xander Bogaerts scored the tying run on Joel Peralta’s wild pitch in the seventh and Victorino followed with an RBI infield single. Dustin Pedroia drove in Bogaerts with a sacrifice fly in the ninth to make it 3-1, and Uehara struck out Evan Longoria to end it.

The resilient Rays won four win-or-go-home games over the previous nine days and led 1-0 this time before Boston rallied.

David DeJesus snapped a scoreless tie with an RBI single in the sixth and Boston squandered several opportunities before finally breaking through in the seventh.

Bogaerts, pinch-hitting, drew a one-out walk and raced to third on Jacoby Ellsbury’s two-out single off Jake McGee. The Rays brought on their sixth pitcher, Peralta, and the game shifted suddenly on his first pitch, which skipped in the dirt past catcher Jose Lobaton — allowing the tying run to score.

Ellsbury was stealing second on the pitch and continued to third when the ball rolled toward the backstop. Victorino beat out a slow chopper to shortstop, putting the Red Sox ahead 2-1.

Breslow pitched 1 2-3 scoreless innings for the win. Uehara earned a save, bouncing back from Lobaton’s ninth-inning homer in Game 3.

Tampa Bay won three win-or-go-home games just to get into the division series last week. Coming from behind in another elimination game Monday gave them hope of taking the series back to Fenway Park, where the Rays were outscored 19-6 in the first two games.

The trip to the ALCS will be Boston’s first since 2008, when the Red Sox lost in seven games to Tampa Bay.

When the Red Sox acquired Peavy from the Chicago White Sox at the trade deadline, they had nights like this in mind. The 32-year-old right-hander made his third career postseason start 2,562 days — a span of seven years, five days — after starting Game 1 of the NL division series for San Diego in 2006.

Both he and Rays starter Jeremy Hellickson were working with plenty of rest.

Although he pitched two innings in a simulated game last week while the Red Sox were waiting to learn who they would face, Peavy hadn’t appeared in a major league game in 13 days. Hellickson hadn’t pitched since Sept. 27, and his selection as Tampa Bay’s starter in an elimination game was somewhat of a surprise.

Although the 26-year-old righty made a team-high 31 starts this season, Hellickson lost seven of his last eight decisions — winning just once after July 26. His career-high 5.17 ERA was the second-highest in the AL to Joe Saunders’ 5.26 with Seattle, but Maddon said he was confident a well-rested Hellickson would perform better than he did down the stretch.

And for one inning, he did.

But after a 1-2-3 first, Hellickson walked David Ortiz and Mike Napoli on eight straight pitches to begin the second. Daniel Nava singled to load the bases, and Maddon had seen enough.

Jamey Wright, an 18-year veteran in his first postseason series, replaced Hellickson and worked out of the jam by striking out Jarrod Saltalamacchia and getting Stephen Drew to hit a hard liner that first baseman James Loney caught and turned into an inning-ending double play with a heads-up throw to second to catch Napoli off the bag.

A foot higher and Drew might well have had a three-run double. Instead it was more frustration for the Red Sox, who went 2 for 14 with runners in scoring position during Monday night’s 5-4 loss in Game 3.

The AL East champions also failed to score with runners at first and second and two outs in the fourth against Matt Moore. They did it again against Alex Torres in the fifth.

Peavy, meanwhile, escaped a tight spot in the third when DeJesus grounded back to the mound to begin an inning-ending double play after Yunel Escobar and Lobaton singled with one out. Peavy wasn’t able to do it again after Escobar doubled off the left-field wall to begin the sixth.

DeJesus, acquired in an August trade and also in the postseason for the first time, lined a 1-1 pitch to right field to drive in Escobar.