Jacoby Ellsbury nearly hit a homerun, Brett Gardner actually did, and the Yankees snapped a four-game losing streak with a 2-1 win over the Oakland Athletics on rainy-turned-sunny afternoon at Yankee Stadium in the Bronx.

Masahiro Tanaka failed to strike out five batters for the first time in his career, but he did pick up a quality start for the 12th time in 12 starts this season, earning his 9th Major League win with six innings of one-run ball.

The Athletics took a 1-0 lead two batters into the ballgame when John Jaso took Tanaka deep with a solo homerun to right field. It was Jaso's 6th homerun of the season, and the first homerun given up by Tanaka in nearly a month.

Tanaka settled in after the homerun and only gave up four more hits over the next five innings, with a walk and four strikeouts to his credit.

Ellsbury nearly put the Yankees on the board with a two-run homerun in the bottom of the 1st inning. Following a Derek Jeter single, Ellsbury lined a ball off of the top of the right field wall. It was originally ruled a homerun, but thanks to the power of instant replay, was changed to a double, and the Yankees would go scoreless in the frame.

The Yankees got the run back in the 2nd thanks to some production from the bottom of the lineup. Brian McCann, the No. 7 hitter, slapped a double the other way into left field, then Alfonso Soriano singled to center field to score McCann, tying the game at 1-1.

An inning later, Gardner led off the 3rd with a solo homerun deep into the right field seats. His 4th dinger of the season put the Yankees up 2-1 -- the lead they would keep until the over end thanks to solid pitching from Tanaka and the bullpen.

Dellin Betances tossed a scoreless 7th inning, collecting another strikeout. Adam Warren gave up singles to the first two hitters he faced in the 8th, but battled back to strikeout two of the next three hitters, including Yoenis Cespedes, to get out of the inning unharmed. Then David Robertson took over in the 9th and locked down his 13th save of the season.

The Yankees will now hit the road and head to Kansas City to open a three-game series with the Royals, starting tomorrow night at Kauffman Stadium. Chase Whitley and Jeremy Guthrie will square off in that matchup at 8:10 pm ET.