NEW YORK (AP) Danny Duffy noticed a flaw in his delivery a few weeks ago: His front hip was opening too soon and he was yanking pitches.

''Obviously, it takes more than 30 pitches in a side session,'' he said. ''Repetition is everything.''

Duffy's mechanics seemed fixed.

Duffy defeated the New York Yankees for the second time in a six-day span and rookie Jorge Bonifacio capped a three-run, seventh-inning rally with a go-ahead, two-run homer that led the Kansas City Royals to a 6-2 victory Tuesday night.

All scoring came on home runs. Lorenzo Cain , Whit Merrifield and Mike Moustakas also connected for the Royals, who went deep four times in a span of nine batters in the seventh and eighth.

''You don't have to manufacture runs when you can put some swings like that on the board,'' Royals manager Ned Yost said.

New York rookie Jordan Montgomery took a one-hit shutout and 2-0 lead into the seventh before a solo homer by Cain, who had been hitless in 14 at-bats.

On the 22nd anniversary of Mariano Rivera's major league debut, the Yankees' usually reliable bullpen flopped: Adam Warren (1-1), Jonathan Holder and Chasen Shreve all allowed long balls.

Home runs by Aaron Hicks in the fourth and Chris Carter in the fifth staked New York to a 2-0 lead against Duffy (4-3). The 28-year-old left-hander struck out 10 in seven scoreless innings to beat Montgomery in Kansas City last week, and Duffy got a key out in the fifth Tuesday when Starlin Castro stranded the bases loaded with an inning-ending flyout.

Duffy gave up two runs and six hits, struck out seven and walked two, his fastball ticking up to 96 mph - about 2 mph above his average this year. Kansas City's opening-day starter, he had been 0-3 in his previous five outings before reviving against the Yankees.

New York put two on against Joakim Soria in the eighth, and first baseman Eric Hosmer leaped to snag Chase Headley's two-out liner. Jacoby Ellsbury bounced into a game-ending double play when umpire Roberto Ortiz ruled Carter ran out of the baseline to avoid Merrifield's tag before the second baseman threw to first.

''It's just a poor call. I don't know how he calls that,'' Yankees manager Joe Girardi said, maintaining Carter remained on the dirt near the infield grass

In the best of his eight big-league starts, Montgomery began 17 of 22 batters with strikes and walked none for the first time, although he did get four warning-track flyouts.

''I was moving in and out, throwing a two-seamer and fastballs up, and going off of that offspeed,'' Montgomery said. ''''I haven't really wavered on confidence. I know what I can do.''

Warren relieved with two outs in the seventh, and Salvador Perez singled to right, just over the outstretched glove of a leaping Castro.

''We just felt I don't want someone tired facing Salvador Perez,'' Girardi said.

Bonifacio hit an opposite-field drive into the right-field seats on the next pitch.

''I just left a fastball up in the zone a little bit and he put a good swing on it,'' Warren said. ''Monty threw great, so you hate to kind of take that away from him.''

Bonifacio has six homers, including four in his last five games. He made his big league debut April 21.

''The kid's been here for 10 years if he's been here for a month,'' Duffy said.

Merrifield connected off Holder leading off the eighth, and Moustakas greeted Shreve later in the inning with his 11th homer, a two-run drive down the right-field line.

''It kind of came back fair, almost. It was pretty weird,'' Moustakas said. ''I wish I could do it with a 7-iron.''

HEADED BACK

Royals OF Alex Gordon was due back in New York late Tuesday following the birth of daughter Joey Lynn, and Yost said Gordon will be available to play Wednesday.

MOVIN' ON UP

Gleyber Torres started at third base for Scranton/Wilkes-Barre, and the 20-year-old went 1 for 3 with a single, walk and strikeout against Columbus in his Triple-A debut. ''I know sometimes it feels like you're a long ways away, but things can happen really quickly in this game,'' Girardi said.

GOING DOWN

Kansas City sent RHP Al Alburquerque outright to Triple-A Omaha.

STREAKING

Yankees backup C Austin Romine was 0 for 3 and is hitless in 19 at-bats.

TRAINER'S ROOM

Yankees: 1B Greg Bird, who hasn't played since May 1 because of a bone bruise in his right ankle, took grounders Tuesday for the first time since going on the DL. He expects to head to Tampa, Florida, on Sunday for extended spring training and then a minor league injury rehabilitation assignment. Bird, who missed 2016 following shoulder surgery, was just 6 for 60 with one homer and three RBIs before going on the DL.

UP NEXT

RHP Luis Severino (2-2) starts Wednesday for the Yankees and RHP Jason Hammel (1-5) for the Royals.

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