It wasn’t a near-no hitter. But it was just as promising.

Making his first start at Minute Maid Park, League City native Jarred Cosart threw seven confident and sharp innings Tuesday during the Astros’ 5-4 come-from-behind victory against the Oakland A’s in an American League West matchup before an announced crowd of 32,249.

Cosart struggled with his command during the initial three frames. But he kept the Astros close and never appeared overmatched, eventually allowing seven hits and two runs (one earned) while striking out four and walking three on 115 pitches (73 strikes).

“The stuff wasn’t as good for me (Tuesday) early in the game. I kind of had a sink. I couldn’t feel any part of my body in the first inning,” said Cosart, who became just the third Astros starter to allow one earned run or less while going at least seven innings in their first two starts.”There was a lot of pressure, no matter what anyone says. I pitched in front of 30-something thousand and I feel like I know half of them.”

Oakland’s Brandon Moss blasted a 95 mph Jose Cisnero offering into the right-field stands with two outs in the top of the eighth for a two-run go-ahead homer.

But Matt Dominguez rocketed a two-run homer to deep left-center field with no outs in the ninth, ending A’s closer Grant Balfour’s streak of 44 consecutive saves and suddenly tying the game at 4.

Astros rookie shortstop Jonathan Villar went 3-for-4 with two doubles and sacrifice bunt, while an improved middle-of-the-infield defense turned four double plays.

Villar scored the winning run with one out in the bottom of the ninth. His double down the left-field line was followed by a walk to Altuve. A throwing error by A’s catcher Derek Norris — an eighth-inning substitution who was trying to catch Altuve in a rundown near first base — then ended up with the Astros rookie safely sliding across home and being mobbed by his teammates.

“It was one of those things where my head just turned so fast. I looked at the catcher, I looked at Altuve, I looked at Villar,” Astros manager Bo Porter said. “I saw once the ball took off to first base, I knew Villar was at least going to make it to third. … The ball ends up in right field and Villar, just being a baseball player, came all the way home for the game-winning run.”

The Astros (34-65) ended a six-game losing streak and downed the Athletics (58-42) for the first time this season in 11 attempts.

Cosart’s outing Tuesday followed a brilliant start, when he held the Rays hitless for 6 1/3 innings and gave up just two hits and no runs in eight-plus frames for his first win.