Charlie Appleby's Charming Thought saw off Ivawood in a thrilling finish to the vision.are Middle Park Stakes at Newmarket.
The runner-up was sent off a hot 1/2 favourite to extend his unbeaten record to four and it looked in safe keeping for much of the six furlongs of this Group One contest.
However, William Buick had other ideas as he laid down a sustained challenge towards the centre of the track as the two colts hit the rising ground.
The judge called a photo but the result was quickly announced, with the Godolphin colt scoring by a nose at odds of 22/1, providing the owners with their first Group One victory in Britain this season.
Buick said: "All along I was sure I'd won. There were two great horses battling out the finish. This horse has done nothing but improve. It's a great training performance by Charlie. There's plenty to look forward to next year."
Appleby said: "It's great to get my first Group One in England out of the way - It was the last roll of the dice for us from Moulton Paddocks.
"He's a horse we've held in high regard from the spring onwards. He just met with a setback in the spring, so we had to be patient with him and it's prevailed now. It was a bold decision by his Highness (Sheikh Mohammed) to supplement him on Saturday.
"William said on better ground you'll see a better horse and he'll probably stay a mile. We felt we had a decent horse today but if he didn't handle the ground there's always next year.
"He'd be one of the sharper two-year-olds, but a lot have three-year-old pedigrees and that's the way we have treated them.
"We are in a rebuilding process and this is one of the blocks that we hope we can build upon."
Ivawood had oozed class on his three previous appearances, making a winning debut at Sandown before claiming Newmarket's July Stakes and the Richmond Stakes at Glorious Goodwood in emphatic style.
But the potent acceleration that has been evident in the past appeared to be lacking on this more demanding surface and he was narrowly outmuscled at the death.
Charming Thought was beaten on his racecourse introduction at Nottingham and although he had since won successive races at Lingfield and Leicester, this represented a huge step up in class.
Buick appeared intent on playing his cards late and his mount really found top gear inside the final furlong to get up within the dying strides.
Gimcrack Stakes winner Muhaarar was a clear third ahead of Irish raider Cappella Sansevero in fourth.
Hannon said of Ivawood: "He wasn't disgraced. He ran a good race. All credit to the winner. He's obviously a very good horse. I loved the way Ivawood travelled.
"He didn't accelerate like he normally does probably because of the ground more than anything else. He's still a very good horse and hopefully he'll come back in May and win the Guineas.
"Our plan doesn't change. He's a big horse and we thought he'd be a horse for next year and we deliberately didn't give him too much this year.
"It's disappointing he didn't win, but it is by no means game over."
Charlie Hills, trainer of third-placed Muhaarar, said: "He's only been beaten a length by two very good horses, so it was a solid run.
"He's been on the go since April and he will get a well-deserved break now. Paul (Hanagan) said he didn't handle the undulations very well, but there should be a lot to look forward to next year."