ST. PETERSBURG, Fla. — It took less than an inning for the era of good feelings established during six weeks of spring training to be mostly forgotten by Yankees fans.

Masahiro Tanaka, considered the one sure thing in a rotation packed with question marks, was tagged for three first-inning runs Sunday en route to the second-shortest outing of his Yankees career.

The 28-year-old righthander allowed seven runs, tying a career worst, in only 2 2⁄3 innings. He put the Yankees in an insurmountable hole against Chris Archer and the Rays, leading to a season-opening 7-3 loss at Tropicana Field in front of managing general partner Hal Steinbrenner and a sellout crowd of 31,042.

Tanaka allowed eight hits and two walks and struck out three.

“I wasn’t really expecting that,” Joe Girardi said, speaking for just about everyone. “That was kind of puzzling for us. There’s going to be days where you don’t have your great stuff, but usually because of his command, he can find a way to get through it. Today he didn’t have his command. You don’t make too much of it. It’s one game.”

The Yankees, who posted an MLB-best 24-9-1 exhibition record, are off Monday before resuming their three-game set Tuesday night. They’ve lost their last six on Opening Day and eight of nine.

advertisement | advertise on newsday

Tanaka was coming off a spring training in which he allowed one earned run in six starts (23 2⁄3 innings).

“When he doesn’t pitch well, you’re surprised no matter what, but it happens, he’s human,” pitching coach Larry Roths child said. “He’s usually very good about having a couple pitches to go to when something isn’t working, but today, because command overall was off, he really had nowhere to go.”

It was Tanaka’s shortest outing since Sept. 27, 2014, when he went 1 2⁄3 innings at Fenway Park.

“Just because it’s the first game, maybe I was a bit hyped up, I feel like I just didn’t have good control over myself,” Tanaka said through his translator. “Today’s Opening Day. You really look forward to this day starting [on Day 1 of] spring training, and just not being able to do a good job today makes it more frustrating.”

Archer was 9-19 with a 4.02 ERA last season, including 0-3, 3.86 against the Yankees. He allowed two runs, seven hits and a walk in seven innings, striking out five.

Yankees videos

“Overall, we just didn’t play well enough,” said Brett Gardner, who went 1-for-4. “We got outpitched and we got outhit.”

The Yankees had nine hits, three each by Starlin Castro and Chase Headley. The switch-hitting third baseman beat the shift each time from the left side, once with a bunt toward third base.

The core Baby Bombers — Gary Sanchez, Greg Bird and Aaron Judge — went 1-for-13, an RBI double by Judge in the second that made it 3-1.

“He was throwing three pitches and throwing them for strikes,” Bird said of Archer. “Hats off to him today.”

The Yankees stranded nine, loading the bases in the seventh and ninth but scoring only in the latter inning.

advertisement | advertise on newsday

In the seventh, Sanchez stepped up with the bases loaded and Archer tiring. But with his 108th and final pitch, he got Sanchez to ground a slider to short for the third out. After Chris Carter’s sacrifice fly made it 7-3 in the ninth, Alex Colome struck out Sanchez with two on and one out.

“We felt pretty good about our chances to score a bunch of runs,” Girardi said of the seventh and ninth. “We had a couple of times where we had some chances to score some runs and we didn’t capitalize today. They did, and that was the difference.”

The Rays took a 7-2 lead after three. That the Yankees made it interesting late at least gave them something to take from the lost afternoon.

“I thought we did a good job,” Headley said. “We fought. We gave ourselves a couple chances to get right back in there and had the right guys at the plate. He’s [Tanaka] going to pitch better than that most games. It’s just one of those days for him. It’s one out of 162.”