NEW YORK (AP) -- Brandon McCarthy pitched a four-hitter and the New York Yankees avoided a three-game sweep, beating the Houston Astros 3-0 Thursday.

Chase Headley #12 of the New York Yankees scores a second inning run past Carlos Corporan #22 of the Houston Astros after a sacrifice fly from teammate Ichiro Suzuki (not pictured). (Photo by Jim McIsaac/Getty Images)

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 girl as the crowd cheered.

McCarthy (5-2) outpitched Dallas Keuchel (10-9) as they both threw complete games without a walk. The Yankees had been shut out in McCarthy's previous two starts.

McCarthy struck out eight in his fourth career shutout and first this season. He was 3-10 with Arizona before being traded to the Yankees in July.

Keuchel gave up seven hits and struck out five.