Murray was far from his best for long periods, losing the first set and seeing his own serve frequently broken by his Spanish opponent.
But the Scot clung on for over two hours and 45 minutes, staving off a match point late in the third set, to claim a 2-6 6-4 7-6 (7/1) win, climbing above Roger Federer in the rankings and lifting the trophy for the second time in his career.
There were a total of 15 breaks of serve in a match that was both ragged and fascinating. But despite the satisfying result and the rankings boost it brings, Murray admitted he would need to do better with his serve if he was to continue winning.
"I served poorly. If I'd served better I could have made it easier and that's something I need to do better in the clay court season," he told Sky Sports 1.
"This week I did a lot of things well but I need to serve better. If I serve better I'll be able to win matches like today [Sunday] more comfortably. It's easier to return on clay so it's even more important to serve well."
Although eager to improve, Murray also suggested he is already on an upward curve.
"It was a strange match. I just managed to fight well in the end in incredibly difficult conditions.
"That sort of match a couple of years ago I probably would have lost...I was up a break three or four times in the third set and kept letting him back in through some loose shots.
"I tried to keep fighting, chased down every ball, made it as hard for him as possible.
"There was a lot riding on the match and I was glad to get through in the end."
Murray looked as if he would start well but threw away two precious break points in the opening game.
Ferrer was more decisive when he had the chance to take the initiative and promptly went 2-0 ahead.
Only a wonderful winner from Murray stopped Ferrer taking the third game to love but it was a rare moment of joy for the Scot as he went 3-0 and then 4-0 down, the latter following an unsuccessful challenge on his own game point.
At 5-0 down Murray finally got on the scoreboard, winning the next two games, but his next service game was the worst yet and he gave up the first set on a double fault.
The second set began in similar fashion to the first, Murray immediately creating break point only to let it go.
But he claimed the next two games, including his first break of the match, to move ahead.
Roared on by a supportive crowd Ferrer clawed back a break to take it to 4-4, only for Murray to break again before serving out the set and force a decider.
The third set was captivating as both men battled wind and humidity but it lacked precision as serve was broken time and again.
Indeed, the first six games went against the server. Murray three times broke Ferrer only to hand back the initiative on each occasion.
Both men were short of their best, with unforced errors and net shots galore.
The sequence ended when Ferrer held the seventh and Murray duly followed suit, making it 4-4 with a classy backhand pass.
Murray looked to have made the decisive move when he took a pair of crucial points to break once again and leave himself 5-4 up and serving for the win.
Yet Ferrer defied, putting together a run of four points from five to break Murray and restore parity.
After holding for the second time, Ferrer reached match point on the Murray serve and would have taken the win had a dramatic challenge gone his way.
Instead, Murray's shot was just in at the base line and he forced the tie-break.
With Ferrer wilting, Murray summoned one last push and won the first four points on his way to a 7-1 tie-break success that brought a second Sony Open success and second place in the ATP standings.