Ribchester was considered the favourite as he looked for a third straight win after his arch rival Churchill was pulled out because of the heavy rain.
With the ground very soft at Goodwood, it was Here Comes When, under Jim Crowley, who powered through the rain to overtake a faltering Ribchester in the final two furlongs of the mile-long Group One.
The Richard Fahey-trained Ribchester ran a strange race, leading from the front, before rallying in the final half-furlong to finish second after looking to have run out of gas.
“I wasn’t comfortable from the three (furlong marker) to the two,” said Ribchester’s jockey William Buick. “He didn’t find as much as I thought he would and that’s usually a very strong part of his race, then he stayed on strongly again towards the end when the others got tired in front.
“I was surprised they got to me. Then when they crossed in front of me, it was because I wasn’t going well enough. He’s a gutsy horse, but they are terrible conditions out there. It’s heavy ground — it’s not nice.”
Here Comes When held on to win by a neck to give trainer Andrew Balding his first topflight winner since 2014, with Lightning Spear (8-1) finishing third, having looked a real threat close to home.