The Rays pulled out another stunning win in Monday's home finale as pinch-hitter James Loney homered to lead off the ninth to give them a 5-4 walkoff win over the Orioles.

It was the team's franchise record-tying 13th walkoff win of the season. It was the Rays' first pinch-hit homer of the season.

The win kept the Rays atop the American League wild-card race as they headed to New York then Toronto for the final six games of the regular season. The Rays are one game ahead of the Indians who were idle Monday and 21/2 ahead of the Rangers who play later tonight.

The Rays were down 4-2 going to the seventh but rallied to tie on an odd play. They had the bases loaded after a Jose Lobaton walk a Ben Zobrist single and an Evan Longoria walk. That was not necessarily a good thing as they were hitless in their past 18 at-bats with the bases loaded and 2-for-their-past-27. Wil Myers blooped a ball into shallow right that second baseman Alexi Casilla tracked and caught momentarily but he lost control of it as he collided with oncoming rightfielder Nick Markakis resulting in a two-run single.

Zobrist making his second start of the season in leftfield helped keep it tied throwing out his second runner of the afternoon as Matt Wieters tried to stretch a leadoff double in the eighth into a triple. Zobrist threw out Casilla at the plate to end the seventh.

The last home game of the regular season drew a crowd of 17830 giving the Rays a season total of 1510300 their lowest total since 2007.

The Orioles lost star third baseman Manny Machado to a gruesome-looking left leg injury when he stepped oddly on first base in the seventh.