ST. PETERSBURG -- Erasmo Ramirez came six outs away from stepping into the history books Monday night as the second Rays pitcher to throw a no-hitter.

Unfortunately for Ramirez, Carlos Beltran had other ideas when he led off the eighth by ripping a single off first baseman Richie Shaffer's glove for the Yankees' first hit in the Rays' 4-1 loss at Tropicana Field.

Matt Garza threw the only no-hitter in Rays history on July 26, 2010, leading the Rays to a 5-0 victory over the Tigers at Tropicana Field.

Ramirez was feeling it Monday night even before he threw his first pitch. Pitching coach Jim Hickey "came in after [Ramirez's] bullpen warmup session and said he looked really good, best he's seen in a while, so that was really encouraging," Rays manager Kevin Cash said.

That carried over into the game. Ramirez was in complete control through seven innings, with Mikie Mahtook's dazzling play in right field in the seventh on Brian McCann's shot to the wall serving as the closest the Yankees came to breaking up the magic.

"When he did the play, I just felt like my soul just come back to my body," Ramirez said. "After that play, my mind was just set up to continue being aggressive and keep the ball down."

Video: Must C Catch: Mahtook catch preserves no-hit bid

Though Ramirez felt better about his chances after Mahtook's play, he saw the dream come to an end as Beltran was the first batter he faced in the next inning. Nobody questioned the official scorekeeper about awarding Beltran a single given the drive that slammed off Shaffer's glove.

"Unfortunately, took a bad hop and bounced way high up on me," Shaffer said. "Just wasn't able to knock it down. It just popped up too high. But it was a great job by Erasmo the whole game. He pitched his butt off. So if there was any way I could have put a body on it and knocked it down, I would have. Sometimes there's just no way."

Video: [email protected]: Beltran rips single to right, ends no-no bid

Two outs later, Ramirez called it a night when Alex Colome took over to record the final out in the eighth.

"Not to take anything away from him, but things could have been a lot different with just a couple of inches one way or the other," Yankees left fielder Brett Gardner said. "... He's pitched well against us, and we obviously haven't done a good job against him, but I don't think we'll have to see him again."

In three starts against the Yankees this season, Ramirez has allowed five hits and one run in 18 2/3 innings, notching a 2-0 mark.

Had Ramirez pulled off the feat, he would have recorded the second no-hitter by a Nicaraguan-born pitcher in Major League history. Dennis Martinez remains alone with that distinction with his perfect game for the Expos on July 28, 1991, at Dodger Stadium.

Ramirez allowed no runs on one hit and two walks while striking out six over a season-high 7 2/3 innings. He threw first-pitch strikes to 17 of the 25 batters he faced.

"Maybe the difference today was about how I attacked the hitters, mix the pitches," Ramirez said. "I just used fastball-changeup the whole time. It was a great job between the catcher and the pitcher. [Catcher J.P.] Arencibia did a good job calling the pitches."

Arencibia said Ramirez "was just really commanding every pitch on both sides of the plate."

"He was aggressive," Arencibia said. "He threw the ball in. He made them respect the fastball in. It's tough to respect the fastball in, changeup away, slider in.

"He was throwing a good first-pitch curveball for a strike, which as a hitter, you can't really stick to one plan. He executed, he did a great job. He definitely had the stuff to, I feel like, throw a no-hitter with the way he was commanding stuff. But that's baseball. He just really executed his pitches."