SEATTLE (AP) -- The Baltimore Orioles weren't going to be denied a victory - or making history - even if it took 5 hours and 44 minutes to do it.
Taylor Teagarden stroked a pinch-hit RBI single to right in the 18th inning to help give the Baltimore Orioles a 4-2 comeback victory over the Seattle Mariners on Tuesday night.
The win allowed the Orioles (84-64) to pull within a percentage point of the Yankees (83-63) for the lead in the AL East. The Yankees were rained out Tuesday and will play a split double-header with Toronto on Wednesday.
Baltimore maintained a three-game lead in the wild-card race over the Los Angeles Angels, who beat Texas 11-3 in Anaheim.
The Orioles' success in extra-inning games might be one of the biggest factors keeping them in the playoff hunt. They have won 14 straight extra-inning games for the longest extra-inning win streak since the 1949 Cleveland Indians won 19 straight. Overall, the Orioles are 14-2 in extra-inning games this season, going 9-0 in them on the road.
''It's tough,'' said Nate McLouth, who had three hits. ''When you start going that long, there's a part of you that has to fight the feeling, 'Oh, let's just get this game over with.' Especially in the position we're in. It's a really important game. It's hard to stay locked in that long.''
McLouth opened the 18th with a walk off Lucas Luetge (2-2). With McLouth breaking toward second, J.J. Hardy sent a single through the right-side hole. McLouth continued onto third.
McLouth said it wasn't a hit-and-run.
''I felt like I could get the bag. He had a strike on him so he swung,'' he said. ''It happened to go in a good spot.''
Teagarden then lifted his game-winner down the right-field line. Hardy later scored on Mark Reynolds' fielder's choice.
Tommy Hunter (5-8) picked up the victory. And he did it with a little extra measure of 'good luck.' Just before taking the mound in the 16th, one of the hovering seagulls unloaded on his hat.
''Here I was minding my own business,'' Hunter said. ''Guys were dying laughing. Then everyone said it was good luck. Then we won the game.''
Jim Johnson worked the 18th to pick up his 44th save - most in the majors - in 47 opportunities.
''It's a challenge,'' Mariners manager Eric Wedge said. ''It's a scenario you don't get into too much, but every now and then it happens. It's tough on both sides offensively. Everyone wants it so bad. We had so many opportunities. One more hit and the game's over.''
Orioles manager Buck Showalter added, ''that dugout was alive the whole time, the whole extra innings.''
The Orioles rallied in the ninth off starter Erasmo Ramirez, who had allowed just two hits and was sitting on a 2-0 lead entering the inning. Pinch-hitter Ryan Flaherty and McLouth opened with singles to bring in closer Tom Wilhelmsen.
Hardy dropped a sacrifice bunt to advance the runners. Chris Davis followed with a two-run single to right.
''It tried to be aggressive with the hitters in the ninth,'' Ramirez said, ''just tried to get ahead in the count.''
Wei-Yin Chen went 5 1-3 innings, allowing two runs on six hits. He walked two and struck out two.
It's the first time the Orioles have been 20 games over .500 since the last day of the 1997 season.
It was the longest extra-inning game for the Mariners this season. They are 5-8 in extra innings.
Justin Smoak and Dustin Ackley each had three hits for the Mariners.
It appeared that Chen would breeze through the fourth as the first two batters bounced out to the infield. Casper Wells then drew a walk on a 3-2 pitch. Miguel Olivo followed with his 11th home run on a 1-2 curve from Chen, who had started him with four straight fastballs.
Ramirez retired the first nine batters before McLouth's leadoff single in the fourth, just tipping off the glove of second baseman Ackley. Ramirez then retired the next eight straight before McLouth's double to center in the sixth. Center-fielder Franklin Gutierrez caught the ball on a dive but it popped out of his glove on contact with the ground.
Ramirez, recalled from the minors on Sept. 1, matched his career high with eight innings. He allowed four hits and both runs were charged to him. He struck out six and walked no one.
Both catchers, Matt Wieters and Olivo, caught the entire 18 innings.
''This is the first game I catch two games in one,'' Olivo said.
Showalter said of Wieters: ''I can't tell everyone how challenging it is to catch a game like that, make that many decisions and be right so often.''
NOTES: DH Jim Thome (neck) and LHP Troy Patton (ankle) are finishing rehab assignments at the Orioles' Sarasota facility and could rejoin the club this weekend in Boston. ''They're both close,'' manager Buck Showalter said. ''We'll make the call (Thursday).'' ... RH Miguel Gonzalez and RH Chris Tillman will start in Boston with the third starter to be decided. ... Chen is just the fourth Orioles rookie pitcher since 1954 to make at least 30 starts. He joins Bob Milacki (36 in 1989), Tom Phoebus (33 in 1967) and Brian Matusz (32 in 2010). ... Felix Hernandez was recognized before the game as the Mariners' nominee for the Roberto Clemente Award. ''That's a great honor,'' manager Eric Wedge said. ''Felix is the total package. To see what he does off the field, how he carries himself, how generous he is with his time, with people, it's well-deserved.'' ... RHP Hector Noesi, shelled for six runs and eight hits in 1 1-3 innings Monday, is back in the bullpen for the rest of the season. RH Blake Beavan will fill his spot in the rotation, starting Saturday. ... Michael Saunders was ejected in the 10th inning for disputing a called third strike.