Michael Pineda throwing against the Tampa Bay Rays in the...

Michael Pineda throwing against the Tampa Bay Rays in the top of the first inning at Yankee Stadium on April 10, 2017.  Credit: Newsday / J. Conrad Williams Jr.

There was nothing wrong with Michael Pineda’s focus with two outs on this day.

Nothing much wrong with the towering righthander, period.

Demonstrating why the Yankees continue to dream big about him, Pineda was perfect through 6 2⁄3 innings Monday afternoon in an 8-1 victory over the Rays in the home opener at Yankee Stadium.

“He had control of his emotions, he had control of his pitches, he had control of the game,” catcher Austin Romine said. “At no point in time did he lose that control. The stuff that he has, he has the ability to dominate every time he goes out.”

Evan Longoria, long a Yankee-killer in his career, broke up the bid for a perfect game with two outs in the seventh, lining a hanging first-pitch slider — one of the few misplaced pitches of the 93 Pineda threw — down the leftfield line for a double.

Mindful of Pineda’s past troubles with two outs — opponents had a .325/.383/.598 slash line with 13 homers in such situations last year — pitching coach Larry Rothschild and Romine quickly went to the mound for a visit.

“Keep it going, let’s go, you still have a job to do,” Romine said of the message. “He understood. All that perfect game, no-hitter, that’s fun stuff to talk about, but he had a job that he wanted to do, and that was to get the team a win.”

Pineda, who allowed one run and two hits in 7 2⁄3 innings after giving up four runs and eight hits in 3 2⁄3 innings in a loss to Tampa Bay last Wednesday in his first start, responded by striking out Brad Miller with a slider that was filthy all afternoon. That was the last of his 11 strikeouts.

Pineda gave up a home run by Logan Morrison in the eighth, but the Yankees scored five runs in the bottom of the inning. In a span of four pitches, Matt Holliday had a run-scoring double, Chris Carter had an RBI triple and Starlin Castro hit a two-run homer, with Rays leftfielder Mallex Smith slamming into the bullpen wall on the triple and rightfielder Steven Souza jr. slamming into the rightfield wall on the homer.

Aaron Judge and Chase Headley also homered as the Yankees (3-4) racked up 10 hits in beating Alex Cobb, who got the victory against them and Pineda last week.

Before Longoria’s hit, Joe Girardi said the feeling in the dugout was that Pineda had the kind of stuff that might produce something historic.

“The thinking is, it’s going to be another special day here at the Stadium,” Girardi said. “I thought he had a shot. His pitch count was down. I started thinking, OK, if he’s at 100 pitches through eight, how far do I let him go? I would have sent him back out.”

Pineda, who said he wasn’t focused on throwing a perfect game but knew his stuff was good, had a positive feeling about his changeup in the bullpen.

“You saw the action,” Pineda said of the pitch while warming up. “I said [to myself], the changeup’s going to be the good pitch today and I’m throwing it.”

Romine said the changeup was “the best I’ve seen” and added: “The slider was devastating, as it always is.”

“He was just throwing the ball where he wanted to,” said Longoria, who struck out in his first two at-bats. “He had full command of all of his pitches today. Really, he made two mistakes — one to me that he made and the one that Morrison hit out of the ballpark.”

Pineda, who did not walk a batter, left to a thunderous ovation from the sellout crowd of 46,955, which started standing in the fifth inning when a Rays batter got to two strikes.

“The fans were excited with two strikes,” Pineda said with a smile. “When I struck out a hitter, they were so happy. I was happy too.”

More Yankees headlines