In another huge upset, Miesha Tate snatched the world bantamweight crown from Holly Holm, choking her unconscious in the final round to take the title.
Following a week of trash talk between the two, a stunned McGregor was somewhat humble in defeat.
“I thought I took him in the first round. I’m humble in victory or defeat,” he said in the octagon after the fight. “I took a chance to move up a weight and it didn’t work.
“I thought I landed with some good punches that got him off,” a delighted Diaz said. “I started off slow but I’m faster than anyone later on. My jiu-jitsu is always there for me.”
McGregor, who was denied a chance to become the first fighter to hold two UFC belts at the same time when lightweight champ Rafael dos Anjos pulled out with a foot injury, struggled in the second round after Diaz landed a heavy blow.
McGregor had landed some heavy left-hand shots of his own in the first round, opening up a cut over Diaz’s right eye that streamed blood as he struggled to cope with McGregor’s quick feet and hands.
The 27-year old Irish fighter, who took just 13 seconds to knock out Jose Aldo and win the featherweight crown, couldn’t put the 30-year-old away, and when Diaz landed a punch in the second round McGregor looked stunned.
Sensing that McGregor was hurt, the Californian suddenly seemed more energetic and went after him, firing off a series of hooks and jabs that found their target.
Struggling to stay in the fight, McGregor took it to the mat, but it was a move that backfired in stunning fashion as he suffered more punishment from the heavy-hitting Diaz.
A black belt in jiu-jitsu, Diaz then slipped behind him and applied the choke hold that finished the fight, silencing the thousands of Irish fans for the first time on the night.
A win against Diaz would have left McGregor in the enviable position of being able to take on Robbie Lawler for the welterweight belt, or fighting Rafael dos Anjos for the lightweight title.
UFC boss Dana White had said in the lead-up to the fight that it was hard to deny McGregor at the moment, and a fight against Lawler would definitely draw an enormous pay-per-view audience.
But Diaz, who took on this fight at short notice, will surely believe that the defeat of McGregor means that he deserves a shot at the title.
The fight was preceded by Tate’s sensational victory over reigning bantamweight champion Holm, who waited patiently throughout the fight for her chance to take her opponent down before choking her out late in the fifth round.
“She went out like a champion. I have so much respect for this woman,” the 29-year-old Tate told the octagon announcer as she received the belt.