The Tampa Bay Rays erased a seven-run deficit to beat the New York Yankees 8-7 in 12 innings and clinch the American League wild card playoff berth Wednesday as Boston fell at Baltimore. The Rays' triumph, on Evan Longoria's home run in the 12th, came minutes after Boston squandered a one-run lead in the ninth inning of their rain-delayed contest at Baltimore and lost 4-3. The Red Sox, who held a nine-game lead over the Rays in the wild card race on Sept. 3, were tied with Tampa Bay for the final American League playoff berth going into the final night of Major League Baseball's regular season. “It's just shocking,” said Red Sox pitcher Jon Lester, who couldn't believe his team weren't headed at least for a one-game playoff with the Rays for the wild card spot. Tampa Bay's Longoria hit a three-run home run in the eighth inning that capped a six-run outburst. Pinch-hitter Dan Johnson's two-out, two-strike solo home run in the ninth tied it for Tampa Bay. Longoria won it with a one-out homer that barely cleared the left-field foul pole. The Rays will open the playoffs Friday against the Texas Rangers, while the Yankees will face Detroit in the other American League first-round series. For Boston, Wednesday's game was the culmination of an epic September collapse. Red Sox closing pitcher Jonathan Papelbon struck out the first two Orioles batters in the ninth inning before giving up a double to Chris Davis. Nolan Reimold followed with a double to score pinch-runner Kyle Hudson, and Robert Andino delivered a single to left field that Carl Crawford couldn't handle. It was just the third blown save of the season for Papelbon. Boston's game was halted for one hour, 26 minutes by rain in the middle of the seventh inning. When the rain hit in Baltimore, the Rays trailed the Yankees 7-0 in Florida. But by the time the Red Sox and Orioles resumed play, the Rays and Yankees were tied 7-7 and going into the 10th inning. The Red Sox' 7-20 record in September was their worst for the month since they posted the same win-loss record in September of 1952. Elsewhere in the American League, the Texas Rangers closed the season with a 3-1 victory over the Los Angeles Angels to secure home field advantage in the first round. Rangers catcher Mike Napoli broke a tie in the ninth inning with his fourth homer in two games as Texas set a club record with their 96th win of the season and their sixth in succession. With 14 wins in their last 16 games, the Rangers held off Detroit for the right to host Tampa Bay Friday. The Tigers did what they could, defeating Cleveland 5-4 in Detroit. They will start the playoffs at New York Friday. In other games it was: Toronto 3, White sox 2; Minnesota 1, Kansas City 0; Oakland 2, Seattle 0.