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.

Media playback is not supported on this device
Former world player of the year Messi, 27, has inspired Argentina in Brazil.
The Barcelona forward has scored in all three games and is one goal shy of Maradona's 1986 five-goal haul, but Mehmedi says it is not all about Messi.
"With all due respect for his qualities and class, I think too much is talked about just Messi," said Mehmedi, 23.
Media playback is not supported on this device
"He is exceptional, no question, but that is not all, he has very good players around him. We will not neglect the preparation nor in the game itself," the Freiburg striker said ahead of their last-16 clash.
Argentina are unbeaten in their six previous games against Switzerland but Mehmedi says his side are not heading into the game at Corinthians Arena just to make up the numbers against one of the pre-tournament favourites.
"Swap jerseys with Messi? I'm not here as a tourist," he said. "Switzerland is in the second round of a World Cup."
Mehmedi knows if his side can defeat Argentina in Sao Paulo they will cause one of the biggest shocks of the 2014 tournament in Brazil.
"I know the quality and potential of this team," he continued.
"If we defeat Argentina, we write a piece of World Cup history and many people in Switzerland will be proud of the team.
"I even think such success would see the world take notice, but we are not naive.
"It will take an absolutely top performance of each one of us. And I assure you, everyone will do everything we can to provide these and tearing for Switzerland."
Northern Ireland's Kris Meeke survived a late scare at Rally Mexico to clinch his fourth win in a World Rally Championship event.
[NEXT_CONCEPT]
Lionel Messi is not the only threat in the Argentina team, according to Switzerland's Admir Mehmedi ahead of Tuesday's last-16 World Cup clash.