"You know you're running into a buzzsaw with that (Tampa Bay) pitching staff, but we pitched pretty good, too," Tigers manager Jim Leyland said. "Brad got in some trouble, but he pitched his way out of it."
Penny (9-9) gave up one run and eight hits over 6 1/3 innings. He had gone 1-3 with a 6.99 ERA in his previous five starts.
Phil Coke allowed two doubles, two intentional walks and struck out five over the final two innings for his first save. Leyland stuck to his plan of giving eighth-inning setup man Joaquin Benoit and closer Jose Valverde the night off.
After Johnny Damon hit a two-out double and Evan Longoria was intentionally walked in the ninth, both advanced one base on Coke's wild pitch. Ben Zobrist then hit three foul balls on 3-2 pitches before grounding out to end the game.
"That was awesome," Coke said. "I'm just glad I got him out. That was a battle, and it was fun. I enjoyed myself."
David Price (11-11) allowed two runs and six hits in eight innings. The Tampa Bay left-hander was coming off consecutive road wins against the New York Yankees and Boston in which the AL All-Star was touched for one run and nine hits in a combined 16 innings.
"They've got a good team," Price said. "They're in the playoff hunt right now so they're feeling good about themselves."
The game started after a 20-minute delay because of a weather-related problem with the lights at Tropicana Field. The Rays say thunderstorms in the area affected a power line running into the domed stadium, which caused the problem.
Detroit scored twice in the seventh, ending Price's scoreless streak at 18 consecutive innings, and took a 2-1 lead on Avila's RBI single and a sacrifice fly by Jhonny Peralta.
Avila, who hit a two-run homer in Monday night's 5-2 win over the Rays, has 15 RBIs in 19 games this month.
Zobrist put the Rays ahead 1-0 on a third-inning RBI double. He has 42 doubles this season.
"Overall, this is the kind of game when if you're going to the playoffs, you win, and when you're not, you don't," Tampa Bay manager Joe Maddon said. "We've got to start winning these games to go the playoffs. You have to win 2-1, 1-0, 3-2 games to win championships."
Penny gave up hits in five of his first six innings, but was able to limit the damage. The right-hander left with one out in the seventh after walking pinch hitter John Jaso.
Daniel Schlereth, who replaced Penny, got one out before giving up a single to Desmond Jennings and walking Damon to load the bases. Ryan Perry worked out of the jam by getting a fly ball to center from Longoria.
"Perry got a huge out, that's good to see," Leyland said. "Maybe that's a confidence builder for him."
Tigers designated hitter Victor Martinez, a late scratch Monday because of lower back spasms, had a double in four at-bats.
Tampa Bay CF B.J. Upton, who sprained his right shoulder Monday, struck out as a pinch hitter in the seventh. ... Tigers RHP Al Alburquerque (concussion) could be re-evaluated later this week. ... Detroit RHP Max Scherzer (13-7) will face Rays RHP Wade Davis (8-7) in the third game of the four-game set Wednesday night. ... Rays RHP Alex Cobb, who underwent surgery last Thursday to remove a blockage in the area of his first right rib, was back at the ballpark. The rookie is thinking about keeping the pinkie size rib that was removed during the procedure in his locker. "I think it's a good thought and it's a reminder," Maddon said. "But I do not need to see it."