ST. PETERSBURG, Florida — Grayson Rodriguez could smell it.

He was one out away from completing the sixth inning without allowing a run, a major career milestone for a rookie who has struggled his second time through major league lineups.

But Wander Franco had other plans. He hit a ground ball up the middle, sending in two runs and ending Rodriguez’s afternoon.

A seasoned pitcher might have gotten out of the sixth. But for Rodriguez this was just another test in a season full of lessons for the 23-year-old pitcher.

The Baltimore Banner thanks its sponsors. Become one.

“Anytime you can’t finish an inning, it’s a disappointment,” he said. “My goal was to get through the sixth.”

The Orioles still beat the Rays 6-5 to retake ownership of the AL East, and Rodriguez still put together one of the best outings of his career, allowing two runs on a career-low three hits in 5 2/3 innings. He struck out six and got 17 whiffs, also a first.

“It gives me something to build off of,” Rodriguez said. “Definitely helps my confidence a lot.”

The Orioles have a plan for Rodriguez’s development. He’s a key part of their future — and present. They believe he has the stuff to one day lead their rotation, and he showed glimpses of that potential Saturday.

These improvements, though, came from a trip to Norfolk. The Orioles gave him a taste of the majors early this season, optioning him after 10 starts. They wanted him to work on his fastball, remove his cutter, gain confidence and return as a guy they can consistently rely on to leave the team in a solid position.

The Baltimore Banner thanks its sponsors. Become one.

“I feel like a totally different pitcher,” he said. “Back to what I know, I guess. That’s just being able to go out and get outs.”

In his second outing since returning to the major leagues, he did that and more. Rodriguez faced the minimum through the first five innings, allowing one hit and walking one, each time getting a double play to end the threat. One of those twin killings came from Gunnar Henderson, who made a diving snag and perfectly placed throw to first to get them out of the fifth.

The sixth, though, was where Rodriguez started to falter. He allowed a leadoff walk to Josh Lowe, a mistake that came back to haunt him. Josh Siri then hit a double, and Franco came through with the single to send in the two runs.

“I thought Grayson was unbelievable,” manager Brandon Hyde said. “I’m really impressed with the starts since he came back from Triple-A. Really good fastball command, lost it a little in the sixth. Maybe he got tired, I’m not sure, but all good stuff.”

Rodriguez got most of his run support in the fourth, when James McCann, Jorge Mateo and Austin Hays hit back-to-back-to-back doubles to score all of the Orioles’ first five runs.

The Baltimore Banner thanks its sponsors. Become one.

They held onto a 5-3 lead until the eighth, when Shintaro Fujinami was sent in. Hyde said Friday that he was going to try to ease Fujinami — acquired on Wednesday from Oakland — into high-leverage situations, but a two-run lead against their division rivals is such a spot. Fujinami showed off his 101.5 mph fastball but was unable to command it. He walked two and gave up two runs as the Rays tied the game.

A series of substitutions in the ninth saved the game for the Orioles. Adam Frazier, pinch hitting for Ramón Urías, got a single. McCann had a sacrifice bunt — inches away from his face — and Ryan O’Hearn, replacing Mateo, hit an RBI single to give the Orioles the win. Félix Bautista wrapped it up, his 27th save.

“It just says everything about our team the way we jumped out early, they crawled back in and then [we] found a way to scratch a run in,” O’Hearn said. “I think it was a special win. We have to go get the series tomorrow.”

danielle.allentuck@thebaltimorebanner.com