Jamie Spencer ended a turbulent week with a last-gasp victory on David Brown's Mind Of Madness in the Julia Graves Roses Stakes.
Second in the Norfolk Stakes at Royal Ascot, the colt had disappointed subsequent but was given a typically patient Spencer ride.
The jockey had on Thursday announced that he was quitting the saddle at the end of this season to take up a management role with Qatar Racing Ltd.
Al Fareej and Moonraker were at the head of affairs in the early stages but Mind Of Madness (4/1) quickened up smartly and while the winning distance was only a nose, Spencer waved his whip with delight.
"That meant a lot," said David Redvers, racing manager to owner Qatar boss Sheikh Fahad al Thani.
"It's been a long week and we've had a few seconds. This boy has been on the go a long time, so it's a great training performance. We might look at the Flying Childers now."