NEW YORK (AP) -- It was only fitting the New York Yankees finished August with one last long ball.
DJ LeMahieu homered on the first pitch in the bottom of the 11th inning and the Yankees beat Oakland 4-3 Saturday for their first victory in five tries against the Athletics this season.
''Finally got one against those guys,'' manager Aaron Boone said.
Aaron Judge hit a tying homer for New York with two outs in the eighth, his sixth in eight games. The 6-foot-7 Judge also took a potential home run away from Matt Chapman in the 10th, barely needing to leave his feet for a grab at the right field fence.
''It was about time I caught one at the wall,'' Judge said. ''I feel like a couple of those at the wall have been kind of slipping over.''
Gary Sanchez went deep twice and the AL East leaders finally took down the A's, once again a potential playoff opponent come October. New York defeated Oakland in the AL wild-card game last year, and the Athletics are in a close race with Cleveland and Tampa Bay for the league's two wild cards this season.
New York hit 74 home runs in August, shattering the major league record for any month. The previous mark of 58 was shared by Baltimore (May 1987) and Seattle (May 1999).
''It's lots of fun,'' Sanchez said through a translator. ''We have a powerful lineup and any given moment any of our guys can hit a homer. That's no secret.''
LeMahieu, a batting title and MVP contender in his first season with the Yankees, was 0 for 4 with three strikeouts before sending a 97 mph fastball from Lou Trivino (4-6) the other way to right field for his 24th home run.
''I knew he was getting a hit there,'' Judge said. ''He just always produces.''
It was LeMahieu's third career walk-off hit and New York's first game-ending homer this season.
''It was a pretty good feeling,'' LeMahieu said. ''Didn't really help the team too much at the plate today, so it was good to come through there at the end.''
Cory Gearrin (1-2), the seventh Yankees reliever, tossed two scoreless innings for his first win with the team.
Matt Olson launched a mammoth two-run homer off New York starter Domingo German, who leads the majors with 17 wins. The right-hander gave up two runs and four hits in five innings - and received a pointed pep talk on the mound from Boone before retiring his final batter, Chapman, with two on.
Sanchez homered twice off starter Homer Bailey, who handed German two of his three losses this year. Bailey struck out nine - his most in more than two years - and permitted four hits in 5 2/3 sharp innings.
''We've played really well against a good team. They've got one of the best records in the league,'' Bailey said. ''You're going to lose some tight ones. That's sometimes just how it goes.''
With two outs in the eighth, Judge homered off Joakim Soria into the second deck in right to tie it 3-all. Soria struck out the other three batters in the inning.
Oakland loaded the bases in three consecutive innings beginning with the sixth, but mustered only one run.
''We left 15 on. That comes back to bite you at some point,'' manager Bob Melvin said.
ON SECOND THOUGHT
Chapman gave the A's a 3-2 lead in the seventh with an RBI double off Adam Ottavino that appeared to land just foul down the left field line. There was no replay review, and Boone said his players bailed him out.
''We waited a long time. Ultimately, I think I probably should have challenged it,'' he said. ''That one's on me.''
POWER TO ALL FIELDS
Sanchez hit a 436-foot drive into the second deck in left and later cleared the auxiliary scoreboard in right-center for his 13th career multihomer game and third this season.
BIG DAY AT THE PLATE
Olson also doubled, singled and walked twice. He reached base safely a season-high five times.
The Yankees traded minor league slugger Ryan McBroom to Kansas City for international signing bonus pool money and a player to be named or cash. The 27-year-old first baseman and outfielder hit .315 with 26 homers for Triple-A Scranton/Wilkes-Barre.
Athletics: LHP Sean Manaea is set to come off the injured list Sunday when rosters expand. He will start the series finale, making his season debut after recovering from left shoulder surgery. With a day off Monday, right-hander Mike Fiers (13-3) gets pushed back to Tuesday at home against the Angels to give him extra rest. ... DH Khris Davis is expected back from the paternity list Sunday.
Yankees: LHP Zack Britton exited in the eighth with cramping in his right calf. No tests were scheduled. ... DH-1B Edwin Encarnacion could go to Triple-A Scranton/Wilkes-Barre to begin a rehab assignment Sunday that would likely last a couple of days. He might even be able to return on the current homestand that concludes Wednesday. ''It looks like it's imminent in the coming days,'' Boone said. Encarnacion has been out since Aug. 3 with a broken right wrist. ... CC Sabathia (right knee inflammation) was placed on the 10-day injured list for the fourth time this year. RHP Jonathan Loaisiga was recalled from Triple-A and threw several 99 mph fastballs to pitch out of a bases-loaded jam in the sixth.
Athletics: Manaea went 12-9 with a 3.59 ERA in 27 starts last year and pitched a no-hitter in April against eventual World Series champion Boston. He has been rehabbing in the minors and his most recent outing was a gem: Manaea struck out 12 over seven shutout innings of two-hit ball for Triple-A Las Vegas on Aug. 23 at Tacoma.
Yankees: LHP J.A. Happ (11-8, 5.57 ERA) struck out seven in five innings of two-hit ball to win Monday at Seattle. He is 4-2 with a 3.96 ERA in his career against Oakland.
More AP MLB: https://apnews.com/MLB and https://twitter.com/AP-Sports