Owner Khalid Abdullah has sponsored the race for 22 years yet this was his first victory with Twice Over, an 11-2 shot under Ian Mongan, getting up at the death of the one mile two furlong trip.
It was a fourth Group One victory for Twice Over who finished three quarters of a length ahead of Midday, who won the Yorkshire Oaks last year and went off as 5-2 second favourite.
Trainer Henry Cecil said: "It means an awful lot to win this for Prince Khalid who sponsors it and has been trying to win it for years and years. I thought I'd have two goes this year, as they both deserved to be here, as you saw."
Mongan, securing the biggest win of his career, said: "He's a true champion, this horse, and really stuck his neck out.
"It's really special. I would like to thank the Prince (Khalid Abdullah, owner) and Sir Henry for putting faith in me because this is as good as it gets.
"I didn't think they went particularly quick and I think Midday and Twice Over probably had a bit more turn of foot to go by.
"The way it was looking I thought it might be a dead-heat, but he really stuck it out."
Aidan O'Brien's Royal Ascot winner Await The Dawn was the 8/13 favourite but finished a distant third on the Knavesmire.