New York's comeback followed sharp outings by five relievers, including winning pitcher Jacob Lindgren, who hurled a scoreless top half of the ninth.
Dallas Keuchel started for Houston and turned in a solid tune-up for his Opening Day assignment, spinning 4 1/3 scoreless innings of four-hit ball with three strikeouts. Keuchel threw 58 pitches, 41 for strikes.
Chris Carter provided Houston with a quick lead by belting his first homer of the spring, a two-run blast to dead center field off Yanks right-hander Michael Pineda in the first inning.
Yankees center fielder Chris Young lost his glove while trying to bring the homer back, and left fielder Brett Gardner scaled the fence and retrieved both the glove and the ball, drawing a standing ovation from the crowd.
"The fence wasn't that high," Gardner said. "It wasn't like I was jumping over the Green Monster or anything. Whatever; I've done it before."
Pineda settled down after permitting three hits in a shaky first inning, striking out six over 3 2/3 innings. Pineda scattered four hits in all and did not issue a walk, throwing 42 of 56 pitches for strikes.
"I'm happy because today is a good outing. I'm feeling good," Pineda said. "This is very important for me. I'm feeling great."
Former No. 1 overall Draft pick Mark Appel pitched three hitless innings of relief for the Astros, striking out two and walking one.
Up next: Veteran Roberto Hernandez, who gave up three earned runs and four hits in three innings Tuesday, will continue his audition for the fifth spot in the rotation when he starts Sunday's game against the Pirates at Osceola County Stadium in Kissimmee at 12:05 p.m. CT on MLB.TV. Dan Straily, who walked four and allowed three runs in two innings Tuesday, will also pitch against Pittsburgh while he also competes for a spot in the rotation.
Bryan Hoch is a reporter for MLB.com. Follow him on Twitter @bryanhoch and read his MLBlog, Bombers Beat. This story was not subject to the approval of Major League Baseball or its clubs.