The second-ranked Nadal's 21st straight victory on clay followed up his eighth straight win in Monte Carlo, as Nadal won the 10th all-Spanish ATP final for a 48th career win.
The sixth-ranked Ferrer lost his fourth Barcelona Open final to Nadal, who saved 12 of 15 break points for a 34th straight victory at Barcelona.
Nadal skipped toward the net in celebration after hitting a backhand winner on match point. The six-time French Open champion displayed his normal resilience and steady play to overcome Ferrer in a match marked by grinding rallies and spectacular shotmaking more reminiscent of a major final.
"This is the hardest match I had on clay court this season, David always takes you to the limit," Nadal told Spanish state TV. "A bit of it was lottery, luck fell on my side today."
With a warm sun bearing down, the players exchanged early breaks before settling into a slugfest of powerful groundstrokes with long rallies often won by magnificently struck winners to the line.
Neither player let a shot go unchallenged with the rhythm only disrupted in the fourth game when both players stopped as medical staff helped a spectator in the stands.
Nadal saved seven of eight break points in the first set, including five which were set points for Ferrer in the 12th game. He fired an ace to save the last before holding for the tiebreaker, and Ferrer's double fault allowed Nadal to get ahead 4-1 as he took the first set in a grueling 93 minutes.
Ferrer saved a triple break point, but then handed Nadal a 3-1 second-set lead when his forehand sailed long.
Nadal showed a dip in concentration on his next service game as he was forced to save a triple-break chance before netting on the fourth opportunity to let his opponent back in.
Ferrer converted another break point when Nadal double-faulted to lead 5-4, but then hit wide on serve to be broken after Nadal's incredible scramble had set up the break chance.
After serving to love to lead 6-5, Nadal's superb crosscourt forehand winner put him ahead as he broke Ferrer for the fourth time to pick up the $400,000 winner's check in 2 hours, 41 minutes.
"Like always, Rafa," said Ferrer, who has three wins already this season. "I've lost four times but four times against a great."