The Spaniard, who had squandered two match points in a nerve-shredding fourth set tie-breaker, added a first All England Club title to his four French Opens.
Nadal's victory made the 22-year-old only the third man to win the French Open and Wimbledon in the same season, and the first since Bjorn Borg in 1980.
The win also ended Federer's six-year, 65-match winning streak on grass, who said he had been beaten by the better man on the day.
"I tried everything," he said. "Rafa is a deserving champion - he just played fantastically. It is a pity I didn't win but I will be back next year."
At four hours and 48 minutes, it was the longest final in Wimbledon history, beating the four hours 16 minutes it took Jimmy Connors to beat John McEnroe in 1982.
The first serve and volley came after four hours and 35 minutes, showing how both players forced each other back with powerful baseline shots.
Nadal shrugged off a rain-enforced 35-minute delay to the start to break first to lead 2-1 with Federer desperately chasing the Spaniard's power-packed forehands.
Nadal then fought off a break point in the next game to back up his advantage which stretched to 4-2 as the world number two edged Federer in some brutal exchanges in tricky, gusty conditions on Centre Court.
Nadal unleashed a 96mph forehand to claim the opening set - the first set Federer had dropped in the 2008 tournament.
The 26-year-old Swiss ace shook off his inhibitions to sneak to a 3-0 lead in the second set before Nadal battled back from 1-4 down to open up a two-set lead when Federer netted a simple-looking backhand.
Nadal saved a break point in the fourth game of the third set and four more in the sixth as the London skies and Federer's mood darkened.
Break points saved
The top seed Federer saved three break points to lead 4-3 and was 5-4 ahead when heavy rain sent the players off court for 80 minutes.
|Federer was hoping to take a record six straight Wimbledon titles [AFP]
On the resumption, a reborn Federer grabbed the third set with an ace in a tense tiebreak before serves dominated the fourth set leading to another tiebreak.
Nadal went to 5/2 but the champion stormed back to lead 6/5 and claim a set point which Nadal saved.
Incredibly, Federer then saved two match points and grabbed another set point at 9/8 before levelling the final when Nadal, stunned by his failing nerve, went long with a forehand.
At 2-2 in the final set, more rain caused a 30-minute suspension, but upon their return, Nadal saved a break point in the eighth game while Federer fought off two in the 11th and three more in the 15th but cracked to give the Spaniard an 8-7 lead.
Nadal went to a third match point which was saved with a inch-perfect backhand.
An unreturned serve gave him a fourth match which he converted to victory when Federer netted a backhand.