ANAHEIM, Calif. - The Yankees' offense spent a fourth straight game resembling the Mets', but on this day it didn't matter.

Getting an outstanding start by Nathan Eovaldi and mostly solid work from their bullpen, the Yankees averted a three-game sweep at the hands of the Angels with a 3-1 victory Wednesday in front of 40,938 at Angel Stadium of Anaheim.

The Yankees (42-38), who are off Thursday after playing 20 straight days, ended the trip 3-4.

Eovaldi (8-2) shut out the Angels (41-38) for 5 1/3 innings before loading the bases in the sixth. Lefty Chasen Shreve got out of the jam, then threw a perfect seventh. Justin Wilson, another lefthander, retired the first two batters of the eighth before Mike Trout hit his 21st homer to make it 3-1.

Dellin Betances came on and retired Albert Pujols. He started what turned out to be a jittery ninth by walking Erick Aybar, who stole second. Betances got David Freese to pop to first and struck out Daniel Robertson but walked Chris Iannetta, bringing up C.J. Cron as the potential winning run. Beteances got ahead of Cron 0-and-2 before striking him to record his seventh save.

Angels righthander Michael Shoemaker (4-7) allowed two runs and seven hits in 52/3 innings.

The Yankees, who had 12 hits but stranded 10, took the lead in the third. Didi Gregorius led off with a single and Stephen Drew bunted him to second. Brett Gardner, 26 for his last 45 coming in, dropped to 0-for-2 with a groundout to first that moved Gregorius to third. Chase Headley, 2-for-23 to that point on this trip, slapped a 1-and-2 pitch to right for a single that made it 1-0.

Eovaldi's toughest jam came in the fifth, when Freese and Matt Joyce led off with consecutive singles. But Eovaldi got Iannetta to ground into a 5-4-3 double play and Efren Navarro to ground to second to end the inning.

After Garrett Jones' long homer to right, his fifth of the season, in the sixth made it 2-0, Eovaldi got into trouble in the bottom half. Johnny Giavotella delivered his second hit to start the inning and, after Calhoun struck out, Eovaldi walked Trout, bringing up Pujols. The slugger, coming off a June in which he hit 13 homers to give him 24, walked on four pitches to load the bases.

Joe Girardi called on Shreve, who had not allowed a run in his previous 14 appearances, to face the switch-hitting Aybar. Shreve fell behind 1-and-0 before getting him to pop to short. He retired Freese on a grounder to third -- Mark Teixeira made a good scoop on Headley's throw in the dirt -- to end the inning. Shreve has retired 56 of the last 67 batters he has faced.

The Yankees failed to extend their lead in the seventh. Drew doubled off the wall in right-center against lefthander Cesar Ramos and Gardner bunted Drew to third. Mike Scioscia brought on righthander Fernando Salas to turn the switch-hitting Headley around. With the infield in, Headley banged into a 4-2 force and Salas struck out A-Rod for the third out.

The Yankees made it 3-0 in the eighth on Gregorius' second hit, a bases-loaded single.