Fairmile gave 17-year-old Adam Kirby the biggest success of his fledgling career with a thrilling victory in the 47th John Smith's Cup at York.

The winner's trainer Walter Swinburn famously jumped to stardom as a teenager on Shergar and while Kirby has no Derby hero to give him a quantum leap up the jockey's ladder, he is quietly going about his business and needs just 19 winners to lose his 3lb claim.

He showed admirable coolness in the saddle in a typically rough race for this prestigious handicap.

When his original plan did not work he slipped into Plan B mode, bringing Fairmile down the outside to lead inside the final furlong.

The 6-1 joint-favourite battled on bravely to beat the unlucky Bravo Maestro (12-1) by three-quarters of a length, with Boo (50-1) half-a-length away third and Forgery (8-1) a short-head back in fourth.

"It's great feeling. I've come here and it's a big achievement for me and the horse," said Kirby.

"It didn't go to plan. You've got so many runners so it's not going to happen. Thankfully Plan B came up good!"

Swinburn missed his biggest win in his second full season as a trainer as he left earlier in the day for a week's family holiday in Spain.

While Kirby enjoyed a dream run, 5lb claimer James Doyle suffered a nightmare in comparison on the runner-up.

His trainer Nick Littmoden said: "The last three races now we haven't had a run. The winner got a run down the outside while we were still looking for a can opener.

"We were drawn low and we had to ride him in a manner to hold him up which means you could get trapped.

"Hopefully we'll have better luck in the Ebor back here next month. He's a very talented horse."

Although northern trainers were out of luck in the big race, it was still a good day for them with Middleham's Mark Johnston leading the way for five Yorkshire-based winners thanks to a double through Linas Selection and Codeword.

Linas Selection (8-11) could return to York for the Great St Voltigeur Stakes next month after a game victory in the John Smith's Extra Smooth Silver Cup Handicap.

The three-year-old followed up his win at Royal Ascot in style against older horses under Kevin Darley and holds an entry in the Ladbrokes St Leger, also at York. Taking over from his pacemaking stablemate Hearthstead Wings over three furlongs out, the colt kept Balkan Knight at bay by a length.

Codeword (13-2) made a winning debut at the expense of 1-2 hot-pot Vauquelin when Joe Fanning steered him to victory in the John Smith's Median Auction Maiden Stakes by a length.

Fanning also had double cause for celebration, having earlier struck on Fremen.

The David Nicholls-trained six-year-old, who is making up for lost time, took the John Smith's Cask Handicap, his second win for the Thirsk trainer after missing 20 months with a leg injury.

The 5-1 chance, partlyowned by actress Claire King, responded well to Fanning's driving to win by a length and a quarter from Grey Boy.

Richard Fahey is hoping Wyatt Earp can earn his place in the Ayr Gold Cup after showing a useful turn of foot to lift the John Smith's Extra Cold Handicap.

The 13-8 favourite, second at Pontefract four days earlier, held Beaver Patrol by a neck with Connect a length away third.

Bryan Smart's decision to put 5lb claimer Mark Lawson on Avertuoso (13-2) paid off when the two-year-old defied top weight in the John Smith's "Premier Club" Stakes.

Bursting into the lead a furlong out, he had a length-and-a-quarter to spare over Danum Dancer.

As well as Fairmile, the other non-Yorkshire trained winner was Newmarket raider Josie Marcus (12-1) in the John Smith's "No Nonsense Racing" Maiden Fillies' Stakes, Jeremy Noseda's charge winning by two-and-a-half lengths over Pearl's Girl.