Leading by 37.2 seconds heading into the last stage, the Briton narrowly missed parked cars as he went off the road with under one kilometre left.
However, he managed to quickly regroup as he finished 13.8 seconds ahead of world champion Sebastien Ogier.
"I'm a lucky boy. I got caught out on a bump," said Citroen driver Meeke, 37.
"Certainly one way to finish a rally."
Hyundai driver Thierry Neuville finished third, 45.9 seconds behind Ford's Ogier.
Leading by 30.9 seconds after bossing the first two days, Meeke won Sunday's penultimate stage to extend his lead to 37.2 seconds.
That left him having to negotiate the final 21.94km stage around Derramadero.
The county Tyrone man's late mishap left him only seventh fastest on the final stage but it proved enough to clinch a crucial victory following his disappointing performances in the opening two events of the season.
After being strongly fancied to contend for this year's title, Meeke crashed out in Monte Carlo and could only finish 12th in Sweden after another mistake.
Meeke, who competed in the championship for the first time in 2011, earned his first WRC win at Rally Argentina in 2015 and took further victories in Portugal and Finland last year.
The Northern Irishman's gamble of opting for hard compound tyres on Saturday's nine stages despite the threat of rain was crucial to his victory as he extended his lead to take firm control of the event.
Northern Ireland's Kris Meeke survived a late scare at Rally Mexico to clinch his fourth win in a World Rally Championship event.