NEW YORK — Once the Boston Red Sox blew a five-run lead, Quentin Berry suspected he might be called on to use his speed Thursday night.

It was quite a challenge doing so against Mariano Rivera, but Berry succeeded, scoring the tying run on Stephen Drew’s broken-bat single with two outs in the top of the ninth inning.

An inning later, the Red Sox pulled out a 9-8 victory over the New York Yankees on Shane Victorino’s one-out single in the inning at Yankee Stadium.

“I never stole against Mariano, but I had all the info on it,” Berry said. “Our coaching staff does a great job scouting and having everything broken down for you. It’s definitely a lot easier stealing bases up here. Down there, you don’t get that kind of report.”

Berry was acquired from the Kansas City Royals on Aug. 27 just in time to be eligible for the postseason. He stole 30 bases in 34 attempts in 99 combined games for Triple-A Toledo, Omaha and Pawtucket, and when the Red Sox acquired him, the move was likened to their 2004 acquisition of Dave Roberts.

Roberts had the famous stolen base against Rivera in the Game 4 of the ALCS, and the Red Sox came back from a three games to none deficit to win the series. When Mike Napoli had a two-strike single to center field off Rivera, it was Berry’s turn to change the game like Roberts did.

“It’s a high pedestal. I’m up for the challenge,” Berry said. “If I can help this ball club the way he did, it’d be a dream come true. I can tell with this ball club the guys that we have, the offense that we have, there’s not going to be very many opportunities, just because we pitch so well and we hit so well. When I do get that opportunity, I try to make the most of it.”

“If it leads us to where Dave did, we’ll take that too,” Boston manager John Farrell said. “We needed that speed off the bench. That one component. We felt like, from a team standpoint, that was the one area that we were a little short. Tonight was the first time he’s been pressed into that specific spot, and he came through.”

On a 1-0 pitch and with Rivera more focused on Drew, Berry got a good jump and took off. He easily made it and then advanced to third when Austin Romine’s throw went into center field.

“He had the benefit of watching Mariano for the two hitters previous to get a read on his delivery,” Farrell said. “Even though there’s nobody on base, we were able to put a clock on it and get a sense of what he’d be looking at. There was no hesitation. First pitch he was off.”

Added Drew: “It’s huge. It kind of changes the game. It kind changes your approach at the plate.”

That changed the approach for Drew, and with Berry at third, he punched the next pitch into right field and the Red Sox tied the game.

Berry’s ability to use his speed and Craig Breslow’s ability to throw two scoreless innings, aided by him throwing to third base to catch Alfonso Soriano trying to steal, set up the deciding inning against Joba Chamberlain (2-1).

Jacoby Ellsbury opened the inning with a single and stole second. Chamberlain appeared to strike out Victorino on a check swing with a 2-2 slider, but first base umpire Joe West ruled he did not go around on the swing and the at-bat continued.

“Yeah, I did (think he swung),” New York manager Joe Girardi said. “It’s frustrating. I thought he went but you have to overcome it.”

“You all saw the replay, I think it speaks for itself,” Chamberlain said.”

On the next pitch, Victorino slapped a 96 mph fastball into right field and Ellsbury came home with the winning run, scoring just as Romine dropped right fielder Ichiro Suzuki’s throw.

“It’s frustrating,” Chamberlain said. “Obviously I got to make a better pitch after that but that’s the plan we had.”

After Victorino’s hit, Chamberlain was ejected by West for arguing as he headed to dugout.

Well before Victorino’s hit and Berry’s dramatic steal helped give Boston its 12th win 16 games, it seemed like the Red Sox were on their way to an easy victory. The Red Sox held a 7-2 lead after Ryan Lavarnway’s RBI single in the seventh, but it all collapsed as the Yankees scored six times against relievers Matt Thornton and Junichi Tawaza and took a one-run lead on Lyle Overbay’s two-out, two-run single.