Dettori took the brave man’s route against the rail before switching his mount wide of rivals inside the final two furlongs and Monarchs Glen picked up well to score by a length from 33-1 chance Euginio.
Mirage Dancer encountered trouble in running and passed the post in fifth place.
Dettori said: “I took a chance and it worked out. I didn’t expect this one to win. It’s been an amazing day.
“I missed it (the meeting) last year and I have been making up for it.
“I love Ascot. It’s been a very lucky place for me. It’s a team effort, though, and John is on fire.”
He added: “I had no plans. He’s a quirky horse and he relaxed for me.
“I was reaching for my can opener at the furlong marker because I thought I’m never going to get out of this, but then we were able to wriggle our way through.
“When I got to the front I was half-shaking my head thinking ‘I can’t believe this has happened’.
“That was my 59th winner at Royal Ascot. I’ve got all week to get to 60. Let’s hope I can do it.”
On his treble, he said: “A fantastic day for the whole team. To have three winners in a week is amazing. To have three winners on the first day is fantastic.”
And on receiving the trophy from the Duchess of Sussex (Meghan Markle) for his win in the St James’s Palace Stakes, he said: “When I told her my son would be very pleased I got the trophy from you she kind of giggled.
“I think my kids will be more impressed about that than winning the race.
“It’s great to have such young royalty to present the trophy. I was very humbled.”