Frankie Dettori grabbed the glory on Jimmy Styles for trainer Clive Cox in the William Hill (Ayr) Gold Cup.
The Italian jockey made his move wide of the far side group and only got up in the closing stages on the 14-1 shot.
Dettori was at his strongest to win the £150,000 sprint handicap by a head from Barney McGrew (20-1). Knot In Wood (11-1) was three-quarters of a length away third with Evens And Odds, the 7-1 favourite, fourth.
Dettori said: ``Brilliant, it's a great race to win, I've never won it before and I'm thrilled.
“I was following Roger Charlton’s horse (Genki) early on and my horse stayed on really well.”
Cox had wanted to nominate stall 19 for his horse but was given 15 when he lost connection on his phone at Thursday’s draw ceremony, but all that was forgotten.
“We lost the connection, it happens to everybody and it doesn’t matter now,” the Lambourn trainer added.
Cox went on: ``It's fantastic to have won this race. He has always promised to be a good horse and I'm pleased for everyone in the yard. We have had a tremendous year and this is the icing on the cake.
“I did not think a week ago the ground would come right for him with all the rain they had, but it did and I couldn’t be more delighted.
“We’ll have to talk to the owners about it and I don’t know what we will do with him.”
Michael Dods, trainer of runner-up Barney McGrew, said: “We have no excuses really though Tom (Eaves) said he clipped heels early on and nearly fell.
“His run was timed to perfection. He got there at the right time and was just mugged on the line.”
Trainer Richard Fahey was responsible for third-placed Knot In Wood and said: “He’s run an absolute blinder, he is a legend.
“He’s come there and given everything he’s got, but the weight just did him.
“He always pulls out more for the jockey and the plan is to go for the Diadem at Ascot. He does not have to give weight to everything there.”
Knot In Wood’s rider Barry McHugh added: “He’s run a great race. We came there to win the race, but the weight just did him.”