ST. PETERSBURG -- After winning the first two games of this series despite trailing late, the Rays got a taste of their own medicine.
Robinson Cano knocked a two-run single with one out in the seventh inning to give the Yankees a lead they would keep in a 4-3 win at Tropicana Field on Wednesday in front of 28,033.
Tampa Bay had dominated New York at home lately, winning the previous nine matchups in St. Petersburg before the series finale.
New York scored three of its runs in the top of the eighth, when Rays reliever Kyle Farnsworth -- formerly of the Yankees -- walked four of the inning's first five batters to pull the Yanks within one run. Tampa Bay manager Joe Maddon turned to lefty Jake McGee to face Cano, whose single put New York up, 4-3.
"I wasn't getting ahead of them, first off, on strike 1, which obviously was huge," Farnsworth said. "If you're behind, 1-0, 2-1 ... they're going sit on their one pitch, and they're not going to swing.
"If you get ahead of the guys and make them be aggressive, defenses can sit on their pitch; things would be different. It's all on me for not throwing strikes."
Maddon said he didn't want to use setup man Joel Peralta, who had pitched in the first two games of the series. The manager instead opted to go with Farnsworth, who issued just 12 walks in 2011, when he was the Rays' closer.
Even though Farnsworth struggled in just his second appearance of the season, returning from a strained right elbow, Maddon said he feels comfortable turning to the right-hander in similar situations.
"Kyle Farnsworth is a big part of our present and our future for us to get to the promised land," Maddon said. "He's got to perform, and he shall. I've never seen him do that personally, the four walks. He just needs a little bit more work."
Carlos Pena had given the Rays a two-run lead in the bottom of the seventh with a tiebreaking two-run homer just inside the right-field foul pole that put Tampa Bay up, 3-1.
Pena's 13th dinger of the year came off a slider from Boone Logan, whom Pena said was hard to hit.
"He's very tough; you can understand how good it feels to connect," Pena said of his homer. "In that situation, where we needed it, it feels good to contribute in that way and help my team in such a way that we had an opportunity to win that ballgame."
Both starting pitchers breezed through the first three innings. Rays starter David Price was perfect with four strikeouts, while Yankees rookie David Phelps was hitless with six strikeouts, including four in a row at one point.
"I was getting ahead early," Phelps said. "I don't know if they were taking pitches early and trying to get my count up or what, but I felt like I was [ahead], 0-1, on a lot of hitters. I was able to put them on the defensive from the start."
Tampa Bay opened the scoring in the bottom of the fourth, which began with a walk drawn by Ben Zobrist. After Luke Scott and Jose Lobaton struck out and Zobrist stole second base, Sean Rodriguez singled to score Zobrist and give the Rays a 1-0 lead.
Price gave up his first hit in the top of the fifth with a leadoff single by Cano. After striking out Nick Swisher, Price got help from shortstop Elliot Johnson, who began a double play to hold New York at bay.
Phelps was replaced after 4 1/3 innings and 81 pitches because of a pitch limit set by manager Joe Girardi prior to the game. The right-hander struck out eight and allowed one run on two hits and three walks.
Price allowed his first run in the seventh, when Mark Teixeira homered to left-center field on a 2-1 pitch to tie the game at 1.
"He didn't make any mistakes until that pitch, at least," Teixeira said of Price. "[He was] as good as I've ever seen him. ... He's got great stuff, and then when he locates, he's almost unhittable."
Price took a no-decision and lasted seven innings, giving up one run on four hits and two walks while striking out eight.
"That's a tough lineup," Price said. "We hung in there and battled, and they threw the ball well today as well. It was a typical [American League] East game, and they beat us today."
Greg Zeck is an associate reporter for MLB.com. This story was not subject to the approval of Major League Baseball or its clubs.