The Rays won it all right, although it was anything but easy.
The Rays led 7-1 in the fourth inning and 9-6 in the eighth, but it was 9-8 when Fernando Rodney got Matt Wieters to ground out in the ninth with runners on second and third with two outs. Third baseman Sean Rodriguez backhanded the final grounder while retreating and fired a one-hopper to first to get Wieters by a step.
Rodney got his 10th save in 10 tries in a game that earlier appeared was going to be blowout.
"When I ran out on the field I was high-fiving everybody, yelling, 'We had it all the way,'" manager Joe Maddon said with a slight grin.
Shields earned his sixth win for the Rays, now 2-6 in their last eight games. Tampa Bay entered the series tied atop the AL East with Baltimore and left town happy to have salvaged the finale.
"We never like getting swept," Shields said. "It's a big win."
Zobrist had three RBIs and Johnson scored three runs and drove in two. Pena was 3 for 37 with 14 strikeouts in May before hitting a third-inning double and adding a two-run double in the fourth to make it 7-1.
Pena also contributed with his glove by snaring the throw from Rodriguez for the final out.
"On the last play, it seemed (Rodriguez) fell a little bit and he had to get something on it and obviously Carlos was there to pick him up," said Johnson, who had a great view at shortstop. "(Pena) has a Gold Glove for a reason."
After Baltimore closed to 7-6 in the seventh, Johnson and Zobrist hit successive homers off Troy Patton in the eighth for a 9-6 lead. The nine runs were the most scored by the Rays since April 19, and they needed every one of them.
"This team never gives up," Wieters said. "We had a chance in the ninth and just didn't come through. It would have been a nice game to win, but at the same time you know this team is going to keep playing hard and we're not out of any game. That's how we feel in this clubhouse."
Shields (6-1) gave up six runs, four earned, and seven hits in 6 1/3 innings. The right-hander is 9-5 lifetime against Baltimore, including 6-1 at Camden Yards.
Shields retired eight straight batters before J.J. Hardy doubled in the sixth. Markakis followed with an RBI double and Wieters hit his eighth homer to make it 7-4.
"I wish I could have gotten Wieters out right there," Shields said. "That was a really big moment in the game."
A throwing error by Tampa Bay second baseman Will Rhymes preceded a two-run double by Markakis in the seventh.
After Johnson and Zobrist connected in the top of the eighth, Nick Johnson hit a solo shot in the bottom half, his second homer in three games off Joel Peralta.
Orioles starter Jake Arrieta (2-4) allowed seven runs and a career-high 10 hits in 3 2/3 innings. The right-hander has yielded 13 earned runs in his last 10 innings and has only one win in seven starts since opening day.
"I think it really comes down to four fastballs that were elevated with guys on base that they were able to put good swings on it," Arrieta said. "So, really the only thing I take away from it is, just I got to get the ball down."
After stranding runners at the corners in the first inning, the Rays went up 3-0 in the second when Johnson hit an RBI single and Zobrist followed with a two-run double.
Wieters led off the bottom half with a double and scored on a single by Chris Davis.
In the Tampa Bay third, Rhymes snapped a 0-for-13 drought by bringing home Pena with a two-out single. The Rays went up 7-1 when Matt Joyce singled in a run and Pena delivered a two-out double.
Tampa Bay's B.J. Upton struck out four times. ... Orioles OF Xavier Avery, the team's second-round pick in the 2005 draft, went 0 for 4 in his major league debut. ... The Orioles open a two-game series against the Yankees on Monday. RHP Jason Hammel (1-3, 6.69 ERA lifetime against NY) will start for Baltimore. ... Tampa Bay will send Jeff Niemann to the mound Monday night in Toronto. ... Baltimore has lost six straight on Mother's Day.