BALTIMORE — After six innings, the Yankees were headed for a rare laugher. Ivan Nova was cruising and an under-siege offense produced a second straight good night against the Orioles.

But if the first third of the season taught Yankees fans anything, it’s that nothing comes easy for this team.

And Saturday night proved to be anything but easy, though the Yankees ultimately prevailed.

They nearly coughed up a seven-run lead as the Orioles scored six runs in the seventh, but Andrew Miller and Aroldis Chapman slammed the door in the last three innings, allowing the Yankees to escape with an 8-6 win at Camden Yards.

“When you play the Orioles, every run is big,” said Alex Rodriguez, who had three hits, the last of which was an RBI single in the ninth that made it 8-6.

After entering a seventh inning in which the Orioles already had hit three home runs and scored six runs against Nova and Nick Goody, Miller pitched two perfect innings and Chapman got the first two batters in the ninth before walking Adam Jones, who had hit a three-run homer off Goody to make it 7-6. Chapman then caught Nolan Reimold looking at a slider for his ninth save in as many chances.

Aaron Hicks had doubled and scored on A-Rod’s single to give Chapman an insurance run in the top of the inning.

“This ballpark, this time of year, it’s a beautiful place to play, but pitching-wise, it’s probably not everybody’s favorite,” said Miller, a former Oriole. “The ball flies and top to bottom they’ve got guys that can hit homers. They’re a dangerous team.”

The Yankees (26-29) accumulated 12 of their 16 hits through six innings in building a 7-0 lead for Nova.

But Mark Trumbo led off the seventh with his 18th homer, and after Matt Wieters reached on an infield single, Pedro Alvarez homered to make it 7-3. Jonathan Schoop’s single and a walk to Ryan Flaherty brought out Joe Girardi to call on Goody to replace Nova, but Jones pounded a hanging slider deep to left-center for his eighth homer and a 7-6 Baltimore deficit.

Before the bottom of the ninth, a warmup slider by Chapman hit well short in the dirt, skipped up and smacked off catcher Austin Romine’s left thumb, pulling back the nail. Brian McCann, out with a hyperextended left elbow, had to come in.

McCann later said “I’m good to go” if Girardi needs him Sunday, but Romine said that won’t be necessary. “My glove fell off my hand,” he said. “Weird. It’s never happened to me before. But I’ll be fine. X-rays were negative. I’ll deal with it.”

After six brilliant innings, Nova (4-3, 4.41) ended up with a pedestrian line. He was charged with five runs and allowed seven hits.

“I was working down in the zone,” Nova said of his first six innings. “In the last inning, I kind of ran out of gas. That’s what I think. Everything was up in the zone and I almost blew up the game. I’m lucky today.”

The Yankees’ highlight inning was a four-run fourth that extended their 1-0 lead to 5-0. Starlin Castro and Rob Refsnyder (who made his first major-league start at first base) had RBI doubles, the latter with two outs, and Romine added an RBI single.

Castro had an RBI single in the fifth. Jacoby Ellsbury and Brett Gardner pulled off a double steal with two outs in the sixth, with Ellsbury scoring on a close play to make it 7-0.

Orioles righthander Tyler Wilson came in 2-4 with a 3.83 ERA and, from the first inning, seemed behind almost every batter. He allowed five runs and seven hits in four innings.

For the Yankees, second-to-last in the AL in runs (203) coming into the game, it was a third straight game with at least five runs.

Having seen far too many slumps already this season, though, Girardi wasn’t ready to declare it the start of a roll.

“I sure hope so,” he offered.