Ridden by Richard Hughes, The Fugue came through late to edge out the long-time leader Timepiece in the final furlong.
It marked the sixth Group One victory of the year for trainer John Gosden, and the 11-4 shot surprised the field, including pre-race favourite Izzi Top, ridden by stable jockey William Buick.
Timepiece held on for second, with Was finishing third.
"She showed her class and Richard rode a typically chilly ride. She's smooth as silk," Gosden said.
"That's what you call a good spare ride," stand-in jockey Hughes added. "She's a beautiful filly and she floats across the ground.
"The more I pulled her back, the more she wanted to go - she was like an elastic band ready to quicken."