Reliever Brad Ziegler's record scoreless streak was ended by B.J. Upton, and Carlos Pena homered leading off the 12th to give the Tampa Bay Rays a 7-6 win over the Oakland Athletics on Thursday.

Ziegler started his career by not allowing a run in 39 consecutive shutout innings _ including the eighth Thursday _ to tie a 59-year-old major league record for relievers. Upton hit an RBI double to give the Rays a 5-4 lead in the ninth.

Pena hit his 23rd homer of the season off Santiago Casilla (2-1) and Dioner Navarro added an RBI single as Tampa Bay moved to 26 games over .500 for the first time in franchise history.

Jason Hammel (4-3) pitched 2 2-3 innings to earn the win for Tampa Bay, which lost closer Troy Percival to a sprained right knee in the ninth. Percival hurt himself while fielding a sacrifice by Mark Ellis and had to leave the game after limping back to the mound.

Hammel allowed an unearned run in the 12th before giving way to Trever Miller. Miller the eighth Tampa Bay pitcher, hit Daric Barton before getting pinch-hitter Rob Bowen to hit a grounder to third to earn his first save in two tries this season.

Cliff Floyd walked four times and scored four runs for Tampa Bay, who won two of three from Oakland and haven't lost a series since the All-Star break.

Tampa Bay missed a chance to win in the 11th inning of the 4-hour, 24-minute game when Rocco Baldelli was tagged out at home plate by Oakland catcher Kurt Suzuki after Casilla's pitch skipped under Suzuki. The ball bounced off the backstop right back to Suzuki, who raced to the plate to get Baldelli.

Pena then hit the first pitch he saw from Casilla in the 12th over the wall in right field to put the Rays ahead for good.

Ziegler, Oakland's rookie reliever who began the season in the minors, tied the major league record for consecutive shutout innings by a reliever when he pitched a scoreless eighth but gave up a one-out walk to Akinori Iwamura in the ninth before Upton doubled down the left-field line to break a 4-all tie.

Ziegler has been one of the few highlights for Oakland in the second half, setting numerous records including the most shutout innings by any pitcher to start a career. The right-hander extended that mark to 39 innings to tie the major league single-season record for consecutive scoreless innings by a reliever set by Cleveland's Al Benton in 1949.

Oakland rallied to tie the game on Frank Thomas' RBI single in the bottom of the ninth but couldn't do much else against Tampa Bay's bullpen.

Carlos Gonzalez hit a two-run homer for the A's, who lost their ninth consecutive series for the first time since 1979. Oakland is 4-21 since the All-Star break, the worst mark in baseball.

Justin Ruggiano tied it at 4 in the fifth with a pinch-hit single to drive in Floyd.

Tampa Bay right-hander James Shields gave up all four Oakland runs and had a season-high five walks in five innings.

A's starter Sean Gallagher had another rough outing, lasting only four innings while giving up three earned runs and walking four.

Notes:@ Thomas's RBI was the 1,703rd of his career, moving him past Reggie Jackson into 20th place on the all-time list. ... Oakland's Jack Cust tied his own team record by striking out in his 19th consecutive game. Cust, who leads the American League in strikeouts, set the record earlier this year.