McCarthy improved to 5-2 with a 1.90 ERA in eight starts since the Yankees got him from Arizona in an early July trade. His first outing for New York came a day after Tanaka, off to an All-Star start as a major league rookie, pitched his last game before an elbow tear put him on the disabled list.
"He's been really, really good," Yankees manager Joe Girardi praised.
Maybe a bit of a surprise, too, considering McCarthy was 3-10 with a 5.01 ERA for the Diamondbacks.
"We knew he was a better pitcher than his numbers indicated," Girardi said.
McCarthy outpitched Dallas Keuchel (10-9) as they both threw complete games without a walk -- the game took only 2 hours, 7 minutes.
McCarthy said his "pitch mix is better" since joining the Yankees, fueling his confidence.
"In Arizona, I'm not getting out of jams, not performing well, and it starts to roll," he said.
New York won for just the third time in 10 games. Chase Headley hit an early two-run double and the Yankees backed McCarthy with flawless fielding.
The Yankees' fans also made fine plays -- sitting in the first row behind the Houston dugout, comedian Chris Rock wound up with a foul ball off the bat of Astros rookie Jon Singleton, and he gave the souvenir to a young boy as the crowd cheered.
McCarthy struck out eight in his fourth career shutout and first this season. The Yankees had been shut out in McCarthy's previous two starts.
Keuchel gave up seven hits and struck out five.
"I feel like I pitched just as good as McCarthy, but he was better today," Keuchel said.
The Astros had won three in a row overall. They were trying to become the first team to come into Yankee Stadium at least 20 games under .500 and sweep a series of three games or more since Milwaukee did it to close the 1972 season, STATS said.
The Yankees took a 3-0 lead in the second when a double by Martin Prado set up Headley's two-run double. Prado and Headley were the only two Yankees starters to previously hit against Keuchel.
Ichiro Suzuki added a sacrifice fly later in the inning.
Dexter Fowler hit a broken-bat double in the Houston fourth -- the barrel reached the infield dirt, the ball two-hopped off the right-field wall -- that put runners at second and third. Marc Krauss followed with a hard grounder off McCarthy's leg and, after taking a moment to locate the ball on the grass, the lanky pitcher zipped a throw to first that ended the threat.
McCarthy escaped another second-and-third jam in the seventh when Singleton struck out -- right after hitting a foul pop to the third-base side that Rock recovered -- and retiring Carlos Corporan on a flyball.
Astros: Closer Chad Qualls didn't pitch in a save situation Wednesday night because of a back problem. Manager Bo Porter said the right-hander got treatment, but didn't want to comment on Qualls' availability.
Yankees: Tanaka is ready to throw to hitters on the side Saturday in his latest comeback effort from an elbow tear. The session will most likely be at Yankee Stadium. ... Slumping Carlos Beltran again didn't play because of his balky right elbow. He recently had his third cortisone shot. Girardi said the team should have a "good idea by Saturday where we're headed with this."
This was the Yankees' fastest nine-inning home game since June 18, 1996, when they beat Minnesota 2-0. ... This was the Astros' fastest game of the season.