It was the first victory for Ireland at a World Cup since Declan Lonergan won in the same event in Cuba in 1995.
Irvine, from County Down, took two silvers at the Glasgow World Cup last November and went on to win the world title in the scratch race and silver in the pursuit at the World Championships in Minsk in February.
However, a crash in Taiwan in March saw him break his hip and he has spent the past six months battling back into the sport.
He showed he was in good form two weeks ago when he took a bronze in the omnium at the European Track Championships.
And on Saturday he made no mistake again, taking a fabulous result after coming home in 7th place in the pursuit earlier in the day.
He clocked 4.26.012 in that pursuit and then immediately went into the points race qualifier.
In the points race final, he saw off the challenge of Denmark’s Lasse Norman Hansen, with the Olympic omnium champion taking silver and top international road sprinter Elia Viviani of Italy winning the bronze.
With just over 30 laps to go Irvine made his move, and took the remainder of the points, with the final verdict decided on the line.
“I must have done something right in rehab, looks like I need to break a leg to get good results,” he joked, referring to his crash and comeback.
“I rode smart for the first half of the race, I didn’t want to race too much, but then I started to use my head. I looked around and other guys were grimacing more than me. I rolled off the front and got in the groove. A Spanish guy came across to me and we committed. It was all or nothing.”
Cycling Ireland head coach Brian Nugent described the results as “brilliant”.
“He only won it on the last lap; fantastic. It came down to the very last sprint. Everyone was trying to get to Martyn, but he was too strong. That was the best race of the competition so far.”
Meanwhile, Corkman Eddie Dunbar was named Irish rider of the year at the Cycling Ireland awards ceremony in Dublin on Saturday.
The Kanturk youngster won the Junior Tour of Ireland in June and represented the country at the UCI Road World Championships in September.