Masar denied odds-on favourite Saxon Warrior to win the Derby at Epsom and give trainer Charlie Appleby his first classic.
Aidan O'Brien had five runners in a field of 12 and was seeking a record-equalling seventh Derby.
But Saxon Warrior could only finish fourth as 16-1 shot Masar, ridden by William Buick, claimed a first Derby triumph for the Godolphin stable.
Dee Ex Bee (20-1) was second, with 6-1 shot Roaring Lion third.
|2018 British classic winners|
|2,000 Guineas, Newmarket: Saxon Warrior|
|1,000 Guineas, Newmarket: Billesdon Brook|
|Oaks, Epsom: Forever Together|
|Derby, Epsom: Masar|
|St Leger, Doncaster: 15 September|
O'Brien claimed his second classic of the season on Friday when son Donnacha rode Forever Together to a four-and-a-half length victory in the Oaks.
Had he made it five wins out of five, unbeaten 2,000 Guineas winner Saxon Warrior was expected to attempt the Triple Crown - last achieved by Nijinsky in 1970 - by competing in September's St Leger.
But O'Brien's hopes of an Epsom double were thwarted as jockey Ryan Moore could find no way through a congested field in the one mile four furlongs showpiece.
Masar, third behind Saxon Warrior and Tip Two Win in the 2,000 Guineas last month, surged to victory by one and a half lengths in the Surrey sunshine.
Appleby, runner-up with Wild Illusion in the Oaks, said: "It's not sunk in yet. It still feels a dream.
"I'm delighted for His Highness Sheikh Mohammed - firstly for giving me the position to be here. I've always said when I started this job I wanted to be the first person to have a Derby winner in Godolphin blue."
Buick, twice a winner of the St Leger, said: "I've come close a couple of times. I've had seven or eight rides and I was wondering if my time was ever going to come.
"He stayed the trip; he travelled beautifully. The Guineas didn't happen for him, but he's a very good horse and the team believed in him.
"Since I wanted to be a jockey this was the day I was dreaming of."
Donnacha O'Brien, who also won the 2,000 Guineas, was ninth on Kew Gardens.
BBC horse racing correspondent Cornelius Lysaght
It is not often that you see Sheikh Mohammed, the ruler of Dubai, perform a little jig, in public anyway, but a first Derby success for his global Godolphin operation - his 'baby' - in the world's best-known race was a long-held ambition and cause for demonstrative celebration.
The Sheikh has poured millions into racing through Godolphin but after initially ruling the roost as racing's undisputed superpower it then found the Coolmore empire coming up on the inside and going by.
The drugs scandal at the stable in 2013 was a body blow too, and Masar represented a first success in a major European Classic for three years; the quality was such however that another may not be too far off.