OAKLAND, Calif. (AP) Royals manager Ned Yost played the percentages when he intentionally walked pinch-hitter Rajai Davis to load the bases with two outs in the bottom of the eighth inning.

The move, which came after Mike Minor's wild pitch left first base open, ultimately cost Kansas City.

Matt Joyce hit a three-run double off Minor to cap a six-run eighth inning and the Oakland Athletics rallied past the Royals 10-8 on Tuesday night.

Joyce also homered and had four RBIs. Khris Davis added his 33rd home run and Matt Olson hit his fourth in five days to help the A's clinch at least a tie for the season series between the former division rivals.

''You're going with the higher-percentage matchup there,'' Yost said. ''Lefties are hitting .130 off (Minor). Joyce is hitting .213 off lefties. It's just a much higher-percentage matchup.''

The loss ended Kansas City's three-game winning streak and prevented the Royals from moving ahead of the Los Angeles Angels in the race for the second AL wild card.

The Royals hit three home runs in the top of the eighth, including Mike Moustakas' 35th, to take a four-run lead before Oakland stormed back against relievers Joakim Soria and Minor (5-5).

Ryon Healy and Olson hit RBI singles off Soria. Matt Chapman and Chad Pinder struck out swinging, and light-hitting Rajai Davis was intentionally walked before Joyce lined a 1-0 pitch from Minor off the left-field wall.

''I kind of saw the cards coming,'' Joyce said. ''Minor has good numbers against lefties, so for me I kind of expected the intentional walk. In situations like that, bases loaded, pitchers kind of have to come to the hitter so for me that was a good pitch to hit.''

Blake Treinen (1-0) retired five batters for his first AL win.

''That's really what the culture we want to set with these guys is: We're going to come back, no matter what,'' A's manager Bob Melvin said. ''The at-bats were as good in that eighth inning as we've seen.''

Drew Butera, Eric Hosmer and Moustakas homered as part of the Royals' five-run eighth. Hosmer also had a two-run double and drove in four.

''It's difficult to swallow, trying to pick up a teammate, trying to pick up your team, trying to get out of the inning and I can't,'' Minor said. ''I feel like I've made pretty good pitches and tonight was one of those nights where I feel like I made some good pitches and didn't have good results.''

Kansas City blew a three-run lead and trailed 4-3 in the eighth before scoring three times off closer Santiago Casilla.

Butera homered after Alex Gordon's five-pitch leadoff walk. It was Butera's third home run, one shy of his career high set in 2016.

After Lorenzo Cain walked to chase Casilla, Hosmer and Moustakas hit back-to-back homers. It was Moustakas' 35th home run, one shy of Steve Balboni's franchise record set in 1985.

All three A's home runs came off starter Jason Hammel. The right-hander, who spent half a season with Oakland in 2014, allowed four runs and eight hits in six innings. He struck out six and walked one.

HOMER HAPPY

Khris Davis, who hit 42 home runs in 2016, has 75 over the last two years - tops in the majors.

SO CLOSE AGAIN

A's starter Chris Smith was in line for his first major league win since June 24, 2008, before Casilla flopped in the eighth. The 36-year-old right-hander, whose only victory came as a reliever with Boston, pitched three-hit ball over 5 1/3 innings and allowed three runs. Casilla also blew a save and cost Smith a win on July 18 by allowing two runs in the ninth.

TRAINER'S ROOM

Royals catcher Salvador Perez (right intercostal strain) threw to second base from behind the plate and played catch, though no timetable has been set for his return. Perez did not swing a bat, a day after hitting off a tee.

UP NEXT

Royals LHP Danny Duffy (7-8, 3.68 ERA) tries to snap his two-game losing streak, while RHP Paul Blackburn (3-1, 3.02) makes his first career start against Kansas City in the series finale Wednesday afternoon. Duffy is 3-0 in six appearances against the A's but hasn't beaten them since 2012.

---

More AP baseball: https://apnews.com/tag/MLBbaseball

Copyright 2017 by STATS. Any commercial use or distribution without the express written consent of STATS is strictly prohibited.