Loving Dream caused an 18-1 upset for John and Thady Gosden and jockey Robert Havlin in the Ribblesdale Stakes at Royal Ascot.

The apparent second-string from the Gosden yard given Frankie Dettori was on Gloria Mundi, the daughter of Gleneagles took a huge step forward from her fifth place in the Lingfield Oaks Trial.

Running in the famous pink colours of Lordship Stud, she hit the front a long way out and there were plenty of challengers queueing up behind her.

Deep inside the final furlong it was Roger Varian's previously unbeaten Eshaada who broke free of the pack deep inside the final furlong to throw down the biggest challenge.

However, to Loving Dream’s credit she found more for pressure and held on to win by three-quarters of a length.

Aidan O’Brien’s pair of Nicest and Divinely were third and fourth while Noon Star, who beat the winner at Wetherby earlier in the season, was forced wide into the straight and finished unplaced.

It was just a second win at the meeting for Havlin after Ardad’s victory in the Windsor Castle in 2016.

Gosden senior said: "Robert committed early and made best use of her stamina.

"Eshaada came late, everyone had a go but she’s very game and very honest and it was a wonderful positive ride by Robert, it really was.

"Trevor and Libby (Harris), the breeders, you go through a lot of agony as breeders but they’ve been fantastic for the game and they’ve never given up and to go and win this race is pretty special."

Perfect Power (14-1) prevailed in a blanket finish to the Norfolk Stakes as Paul Hanagan recorded an emotional success.

Trained in Yorkshire by Richard Fahey, the son of first-season sire Ardad only got off the mark at Hamilton eight days ago.

The field split into two groups, with Go Bears Go making a bold bid on the far side looking to give David Loughnane his second winner at the meeting after taking the closing race on Tuesday, while Wesley Ward's Lucci led the other group.

Perfect Power had plenty to do entering the final furlong, but coming widest of all in the stands side group, he began to hit top gear as close to the rail Project Dante, another northern raider, was also making gains.

Go Bears Go was still in front on the far side and had seen off Cadamosto, as it became a case of which group would come out on top.

There was nothing in it as the juveniles flashed by the post, but Perfect Power just got the verdict by head from Go Bears Go, with the Bryan Smart-trained Project Dante a nose back in third.

Once the result was called, the joy was immediately evident for former champion jockey Hanagan, who only returned to the saddle in August last year after suffering a serious injury at Newcastle in February.

Perfect Power (yellow silks) prevails

He said: "I think this tops the lot. The accident I had last year was a pretty bad one and I just thought I’m lucky to be here at all, never mind riding winners.

"I think early on when I was laid in hospital, I thought I was in trouble. It was only through the rehab and genuine kindness of people that I’ve got back. You just appreciate it when you get a second chance.

"This would be my main (achievement) now because I didn’t think I would get back at all. It was a bad one – I fractured my T4, T3 and T6 (vertebrae), and the T6 was crushed all together. So after operations and physio of countless days, being in a few bad places a few times, to make it back and ride a winner here – it would top the whole lot.

"I’m good friends with Freddy Tylicki and I realise what he’s been through. He’s kind of been my inspiration as well as he wasn’t as lucky as me. I found great inspiration from him, I’ve got a second chance and it didn’t happen for Freddy. I just appreciate the chance that I have got.

"It’s so nice to see the crowds back – what a buzz. The cheer of the crowd was something special."

Fahey has long been a close ally of Hanagan, with the pair enjoying many big days together.

He said: "We were very sweet on the horse. He came out of Tally Ho Stud at the Breeze Ups so we haven’t had him long. Roger O’Callaghan needs to take a bit of credit for this. We took him up on the gallops on the grass and he literally destroyed some of my two-year-olds.

"He was a little unlucky first time, he missed the kick and did everything wrong, but it probably worked in our favour as it meant we got a second run into him which I thought was vital. I was quietly confident he’d run a big race, but I was looking at going over six before a long discussion with everybody.

"I haven’t thought about the future, but I’d have thought we’ll be looking at six furlongs now."

Mohaafeth (11-8F) continued his rapid progression up the ranks when winning a dramatic running of the Hampton Court Stakes.

William Haggas' charge was among the favourites for the Cazoo Derby earlier this month, but heavy rain on the Friday turned the ground softer than the trainer felt his charge wanted.

Having agonised over the decision to run, Haggas took him out just over an hour before the race and immediately nominated this contest as his alternative target – and from the point of view of connections the late switch was justified.

It turned into a messy contest, however, with Matchless, Movin Time and Snapraeterea all racing keenly in the early stages and Jim Crowley content to let them get on with it on Mohaafeth.

Haggas would have been delighted the forecast heavy rain overnight failed to materialise and Crowley moved his mount wide to challenge in the straight.

Unfortunately Mohaafeth then began to hang right handed towards the rail – while also quickening clear with Roman Empire – and although going clear of his only rival, the Frankel colt ended up drifting to his right and Ryan Moore had to stop riding briefly on Roman Empire.

The stewards inevitably had a look, leading to a tense wait for connections of Mohaafeth before he was confirmed the winner by a length and three-quarters.

Haggas was delighted with the result, but was not getting too carried away.

He said: "He’s only up to Group Three from Listed, but he’s a pretty good horse.

"I think it probably didn’t go his way today. Jim was concerned about the horse of Roger Varian’s (Movin Time) who was up the front and he was quite far behind and he said, by his own admission, he’d gone a bit early, but the horse kept going, that’s the main thing.

"He did run across the track a bit, but he’s probably used up a lot of petrol getting there."

Marcus Tregoning registered a first Royal Ascot success since 2003 as Perotto (18-1) landed the Britannia Stakes.

Derby-winning trainer Tregoning had endured a drought since High Accolade won the King Edward VII Stakes in a year he saddled a double, with Nayef – possibly the best horse he ever trained – winning the Prince of Wales's Stakes.

Perotto had his stamina to prove racing over a mile for the first time – which was a marked rise in trip from his two-year-old days when he even ran over five furlongs in the Flying Childers.

Settled at the rear of the pack by champion jockey Oisin Murphy, there was little between the two groups and Perotto made a bold move a furlong out.

Joseph O’Brien’s Liffey River was charging home late but failed to get there by half a length, with Quintillus and Dubai Honour fourth.

Murphy said: "I thought I was Jamie Spencer and missed the break by a couple of lengths. I tacked over to the rail and followed William Buick which was the right decision.

"He put his little head down and his ears back when the pace collapsed. He hit the line hard and could be a horse for Hong Kong."

He added: "I don’t team up with Marcus very much, but he’s a top trainer with a small string and an absolute gentleman.

"This horse was very well prepared today, he gave me a super ride, I’m thrilled, these races are hard to win.

"He stuck his head out, I wasn’t sure about a mile and I rode him very cold.

"I wasn’t given any instructions, but I’m glad it worked out."

Tregoning said: "We discussed plans and decided to drop him out and try to use his electric burst of speed late.

"Oisin is a top-class jockey and we were lucky to get him for our only runner at the meeting.

"This horse is from the same family as Accidental Agent and lots of other good ones, and showed he stays the mile really well."

The famous Juddmonte silks were carried to a poignant victory by Ralph Beckett’s Surefire (5-1) in the King George V Stakes.

It was a first Royal Ascot success for jockey Hector Crouch and possibly a final one celebrated by Teddy Grimthorpe, who steps down from his long-standing role as racing manager to the late Khalid Abdullah on Saturday.

A winner at Leicester 10 days ago, for which he picked up a penalty, the Fastneck Rock colt came with a run down the outside and held off the strong late challenge of Ryan Moore on Sir Lamorak to win by a neck.

Crouch said: "I wanted to get him rolling and to the outside and I knew he would be hard to stop.

"It’s such a privilege to ride in the Juddmonte silks – it’s my second winner for them and the first was only last week at Leicester."

Beckett said: "He’s still a bit green, and showed that at Leicester last week.

"He did just lean in as he was about to hit the front, but it was too far out for the dreaded claxon to sound.

"He’s been a bit of a slow burner, but saw out this tough trip and I hope he will end up a Leger horse."

The closing Buckingham Palace Stakes went the way of John Quinn’s Highfield Princess (18-1), providing jockey Jason Hart with a first winner at the meeting.

Hart said: "She’s just kept working her way up from 57 last year to 92 and has improved with racing. I think she could be a black-type filly.

"I think the way the race panned out suited her. And the rain is getting into the ground and that helped. She’s an honest filly.

"I didn’t think my turn was going to come here, but thankfully it has with this filly."