Dettori delivered a perfectly timed challenge on Country Grammer to claim the win, gobbling up red-hot favourite Life Is Good's lead in the final furlongs. Hot Rod Charlie stayed on strongly to finish second, Chuwa Wizard capping a great night for Japan in third.
The Italian first won Dubai's showpiece event aboard the great Dubai Millennium 22 years ago, and also claimed the trophy on Moon Ballad in 2003 and Electrocutionist in 2006.
Dettori said: "When I got the sniff that this ride might be going I quickly made calls to Bob and he made me sweat! I've known him for 30 years and galloped horses for him in California. Bob said get him out and on the tail of Life Is Good.
"He's a big horse and did exactly what I wanted him to do until the half-mile pole when I thought Life Is Good was getting away from me.
"I started trying something different to get him on the right leg, give him some fresh air and fill his lungs. Passing the furlong marker I thought 'I've won this'. The last furlong was amazing - such a great feeling.
"Life Is Good is one of the best, but if there was a chink in his armour it was the mile and a quarter.
"This is an important race, and Dubai has taken up a good chunk of my life. Coming back it was as if I'm part of the furniture."
Baffert's long-time assistant, Jimmy Barnes, said: "I knew he was a true mile and a quarter horse and we laid out a plan to get the job done.
"He travelled for 26 hours to get to Saudi and came in second, but we knew after that we should give the World Cup a shot."