Despite a long injury-enforced layoff, Velasquez headed into the title unification bout as the heavy favourite, but he was matched by Werdum throughout.
The Brazilian jiujitsu specialist (20-5-1) induced a cut below Velasquez's left eye in the first round and the local favourite struggled to adapt for the remainder of the fight.
With Velasquez tiring in the third round, Werdum drew a laboured take down attempt from the 32-year-old and immediately capitalised on it with a guillotine choke that forced a tap-out from Velasquez at 2:13.
Prior to the main event in Mexico city, Mexican-American middleweight Kelvin Gastelum (12-1) beat the 36-year-old Nate Marquardt (36-15-2) in a second round TKO.
Gastelum's victory followed his first career loss in January against Tyron Woodley and the middleweight hopes to be able to compete in the welterwieght division again in the near future after missing the weight limit in two of his last three fights.
Eddie Alvarez defeated Gilbert Melendez by split decision in the lightweight division despite going through the majority of the fight with his left eye swollen shut following an elbow to the face in the first round of the bout.
In the featherweight division, Mexican Yair Garcia (6-1) got a split decision victory over Charles Rosa (10-2), while Tecia Torres (6-0)claimed a unanimous decision victory over Angela Hill (2-1) in strawweight combat.
On the undercard, 2008 Olympic gold medal-winning wreslter Henry Cejudo (9-0) continued his unbeaten UFC run with a unanimous decision over Chico Camus (15-6).
"I was very sick the last three days, I suffered from food poisoning and I wanted to cancel but I did my best", Cejudo said at the post-event press conference.
"I won the gold in Beijing, now I want to become a champion at the UFC."