"It was his deal," Freiman said of the cut fastball he saw. "That one he always throws."

As a day game after a night game turned into a night game after a day game, John Jaso singled off Preston Claiborne (0-1) to start the decisive rally and went to third on Seth Smith's soft single to shallow left field against Rivera.

Rivera issued only the 39th intentional walk of his 19-year career to Jed Lowrie before Freiman ended the 5-hour, 35-minute game on New York's getaway day to Anaheim for a weekend series with the Angels.

"A little broken-bat blooper over the third baseman, and the other one the same place," Rivera said. "You can't do anything about it."

Freiman knew he had it, raising his right arm in triumph.

"I knew that was not getting to the left fielder. I knew it was falling," he said.

Moments later, Freiman received a celebratory whipped cream pie in the face following his first career game-ending hit -- and Oakland's fifth of 2013 after compiling a major league-best 14 walk-off wins last year. He had entered the game in the top of the 16th.

The AL West-leading A's (41-27) won their 11th in a row at home, 21st in 26 overall, and moved a season-best 14 games above .500 to extend their best start since 1990. They became the first American League team to play two 18-inning games in one season since Oakland and the Washington Senators did so in 1971.

Each team used seven pitchers and threw 255 pitches. In all, 137 batters came to the plate -- short of the season high of 156 during Oakland's 19-inning win over the Angels in April and also the 20-inning game between the Marlins and Mets on Saturday.

"It was very taxing even winning the game. To lose could have been demoralizing," A's manager Bob Melvin said. "These are awful games to lose."

New York made a dramatic play in the bottom of the 15th to keep the game going.

The Yankees had runners in scoring position in each of the extra innings through 14, stranding 11 baserunners. They left 13 on base in all while dropping their seventh in a row at the Oakland Coliseum.

Pitching for the first time in eight days, Jesse Chavez (1-0) struck out seven in 5 2/3 scoreless innings.

Jerry Blevins escaped a bases-loaded jam in the top of the 11th with two strikeouts. Pat Neshek worked out of trouble with runners on first and second in the 12th.

Robinson Cano hit a two-run homer in the first as New York ended a season-long five-game stretch without a long ball, but the Yankees didn't score again on another day of missed opportunities.

"I think it's probably a little more frustrating because you can look at how you had an opportunity here and an opportunity there," Yankees manager Joe Girardi said. "A lot of guys probably look at that, but it doesn't change the result."

It was the longest day game in Coliseum history.

Neither A' starter Jarrod Parker nor New York counterpart Hiroki Kuroda got a decision after a nice pitchers' duel hours before the game ended.

After Smith's tying, two-out double in the third, Oakland didn't reach base again until Jaso's bloop single leading off the ninth.

Oakland won the season series 5-1 for its second-best mark against the Yankees in franchise history. The 1990 club went 12-0.

The A's tied it at 2-2 in the third on a close play at the plate. Smith doubled off the wall in right and the relay throw was on target to Stewart, who tagged Jaso with his glove but had the ball in his bare hand.

Jaso was called safe by plate umpire CB Bucknor, drawing an argument from Girardi.

Earlier in the inning, Derek Norris' RBI groundout scored Chris Young, who drew a leadoff walk. Eric Sogard followed with a single before the A's pulled off a double steal.

Parker, riding a three-start winning streak, was helped by a pair of double plays in the first four innings.

Kuroda's winless stretch reached five starts since he beat Toronto on May 17. He became the third Japanese-born pitcher with 1,000 innings in the majors, joining Hideo Nomo and Tomo Ohka.

Girardi bumped Jayson Nix up to the No. 2 spot in the batting order from eighth a night earlier to shake things up and get the Yankees going, but Nix went 1 for 5 with a strikeout to end the 12th.

Game notes

Yankees captain Derek Jeter had his surgically repaired left ankle examined by Dr. Robert Anderson in Charlotte, N.C., and was cleared to resume baseball activities and running. ... Crisp (bruised heel) and LF Yoenis Cespedes (tight left hamstring) were held out of the starting lineup. ... Rivera received a surfboard and a bottle of white wine from Napa Valley from the A's in a pregame ceremony, along with a $10,042 donation to his foundation. ... The A's are 7-0-2 in their last nine series. ... New York agreed to contract terms with Notre Dame 3B Eric Jagielo, who signed for $1,839,400. He was the 26th overall pick in last week's draft and one of three first-round selections by the Yankees.