LAS VEGAS — The main event of UFC 229 erupted into a violent skirmish moments after Conor McGregor was mauled into submission by Khabib Nurmagomedov.

The Russian battered McGregor over four rounds before eventually locking in a rear naked choke hold from which there could be no escape. McGregor tapped out after 3:03 of Round 4, allowing Nurmagomedov to retain his UFC lightweight championship belt.

Within moments of the end, Nurmagomedov sprinted towards the side of the octagon where McGregor’s team was sitting and hurled his mouth-guard in their direction. Then, appearing to point towards McGregor’s teammate Dillon Danis, he leaped over the top of the cage and jumped into the group.

Chaos ensued, with security struggling to gain control of the fracas, especially when another fight broke out in the octagon itself moments later. Finally, the parties were separated and restrained, but not before further ugly scenes, and Nurmagomedov was announced as the winner. However, as he was escorted out of the area, he was not presented with his belt inside the octagon.

"(McGregor's team) were taunting Khabib and Khabib just said '(expletive) you' and jumped over the fence and attacked them," commentator Joe Rogan said.

TV footage clearly showed two men jumping over the fence and into the octagon, the first of which confronted and engaged with McGregor while the second came from behind and launched several punches at McGregor's head.

Nurmagomedov's coach Javier Mendez told USA TODAY Sports that Dillon Danis, a Brazilian Jiu Jitsu expert who is part of McGregor's camp, "was insulting" Nurmagomedov immediately before he hopped over the fence toward McGregor's crew.

"Dillon set him off, I guess," Mendez said in a text message.

Nurmagomedov was questioned by security from UFC and MGM — which runs T-Mobile Area — after the fight. Rizvan Magomedov, a manager for Nurmagomedov, was detained by Las Vegas police, according to Mendez.

Messages left with the Las Vegas Police by USA TODAY Sports were not immediately returned late Saturday.

MORE FROM UFC 229

KHABIB:Not sorry about post-fight chaos, says Putin 'proud'

WHITE:UFC boss promises significant punishments for brawls

MMAJUNKIE: Reaction from Nurmagomedov-McGregor chaos

SHOUT OUT:Fighter congratulates Brett Kavanaugh after win

The bad blood between the fighters was long and bitter. Back in April, McGregor unleashed an infamous attack on a bus carrying Nurmagomedov in Brooklyn. The Irishman had also repeatedly taunted his rival in the lead-up to the bout in a series of insults.

It all led to one of the most anticipated fights in UFC history with pay-per-view numbers, yet to be released, trending towards record-smashing territory.

Nurmagomedov’s win took his record to a perfect 27-0, while McGregor, coming off nearly two years away from UFC competition, fell to 21-4.

Most of the first round was spent on the mat, after Nurmagomedov got a grip on McGregor’s leg and eventually mauled him to the canvas. The second brought major fireworks, and none of it was good for McGregor. The Russian dropped him with a huge overhand right in the first minute, and if a flying knee that followed had connected the fight would surely have been over.

As it was, Nurmagomedov then threw McGregor down and went on to pound him with fierce blows for most of the remainder of the round.

McGregor looked wearied and short of ideas, his trademark confidence sapped. He had some more fortune in the third, connecting with his patented left hand but was already breathing heavily.

There was not much left. When Nurmagomedov got McGregor down early in the fourth he was able to maneuver himself into optimum position. McGregor had neither the strength nor technique to answer, and the end — and the resulting mayhem — was near.

Follow Martin Rogers on Twitter @RogersJourno.

Contributing: A.J. Perez.