The surging New York Yankees keep coming up with timely hits, defensive gems or key pitches to pull off close wins — and now they have their best unbeaten run in nearly 60 years because of all those little things.

Aaron Judge hit a tiebreaking single with two outs in the ninth inning, Giancarlo Stanton homered for the third consecutive game and the Yankees beat the Oakland Athletics 7-6 on Thursday night for their 12th straight victory.

"We’re playing well, we’re playing for a lot, and it’s a lot of fun to be part of this team," said manager Aaron Boone, who watched from inside for most of this one after his second-inning ejection.

Aroldis Chapman closed it out for his 300th career save, becoming the 31st pitcher to reach the milestone. Jonathan Loaisiga (9-4) struck out two over two innings for the win.

CLICK HERE FOR MORE SPORTS COVERAGE ON FOXNEWS.COM

"To be honest, I never thought about it," Chapman said via translator. "At the beginning I wasn't even a closer, but as you go on with your career there are certain goals that come and you get to reach. I'm very happy."

Joey Gallo crushed a three-run drive in the third for a 6-0 lead before Oakland came back, tying it on Josh Harrison’s homer in the fifth.

Judge doubled leading off the eighth as New York loaded the bases against Sergio Romo, who escaped unscathed. Lou Trivino (5-7) began the ninth hours after manager Bob Melvin said he would remain the closer despite consecutive blown saves after converting 14 straight.

"After what we've been going through, to be down 6-0 and come storming back like that with that kind of fight, at this point in time we're looking for some small victories," Melvin said.

Anthony Rizzo drew a two-out walk from Trivino, and Tyler Wade entered as a pinch-runner. He stole second and reached third on catcher Sean Murphy's throwing error before coming home on Judge's line drive.

New York has the club’s longest winning streak since a run of 13 straight victories from Sept. 1-12, 1961, and the Yankees moved a season-best 23 games above .500 at 75-52.

Stanton connected for his 23rd homer and fifth in eight games moments after a fuming Boone got tossed by plate umpire Todd Tichenor for arguing balls and strikes. Boone repeatedly gestured and yelled before finally making his way to the tunnel and clubhouse.

Brett Gardner homered one out later to back right-hander Jameson Taillon, who didn't reach five innings for a decision but has still won seven straight decisions since a May 31 loss to Tampa Bay in the Bronx. Rizzo added an RBI double in the third.

"All that matters right now is winning," Taillon said. "It doesn’t matter how you get it done."

Matt Chapman and Murphy hit back-to-back homers in the third, the fifth time the A's have done so this season. Chapman drew a bases-loaded walk and Elvis Andrus a two-run single that chased Taillon in the A's three-run fourth.

Oakland right-hander James Kaprielian struck out eight but was clobbered from the start after he had been 2-0 with a 3.31 ERA in three starts since coming off the injured list.

The stumbling A's, who reached the playoffs each of the past three seasons, lost their fifth straight — four by two or fewer runs — on a night attendance was a dismal 8,147, which Chapman called a "little disappointing."

"We've had some really tough finishes," Chapman said. "It seems like we're right there."

TRAINER'S ROOM

Yankees: INF Gio Urshela came off the 10-day injured list after missing 23 games with a strained left hamstring. He started at third batting eighth. ... SS Gleyber Torres (sprained left thumb) has increased his baseball activity with Double-A Somerset and is expected to begin a rehab assignment Sunday. ... RHP Corey Kluber (right shoulder strain) rejoined the Yankees and is set to start Monday on the road against the Angels. ... LHP Zack Britton, dealing with a sprained pitching elbow, is scheduled to be examined Monday by Dr. Neal ElAttrache to determine the next steps and whether to have surgery. ... RHP Luis Severino, who had Tommy John surgery in late February 2020, has been cleared to start his throwing program again after ElAttrache evaluated him.

Athletics: RHP Chris Bassitt will travel back to the Bay Area on Friday following facial surgery in Chicago, where he was hit with a line drive last week. The operation repaired the pitcher's cheekbone that was fractured in three places. ... Also Friday, RF Stephen Piscotty will have left wrist surgery in Arizona. He was examined Thursday by hand specialist Dr. Mark Leber, who will perform the procedure. The A’s aren’t ruling out a return this season. ... RHP Mike Fiers will throw a bullpen Friday for the first time as he works back from a sprained pitching elbow.

UP NEXT

RHP Gerrit Cole (12-6, 2.92 ERA) pitches Friday night on an extra day of rest trying to keep the roll going and win his third straight start.

LHP Sean Manaea (8-8, 3.77) takes the mound for the A's trying to salvage an August win after going 0-2 with a 9.77 ERA in four starts this month — none of which has gone further than five innings.