Djokovic recorded a 7-5, 6-4 decision to win his sixth tournament in as many appearances this season. His winning streak is the longest at the start of a year since John McEnroe opened with 42 consecutive victories in 1984.
Sunday's victory was perhaps the most impressive of the year for Djokovic since it came on clay, a surface on which Nadal has been dominant.
Nadal came into this tournament with a 213-16 career record on clay courts and had won 37 straight matches on the surface prior to Sunday's setback. Djokovic's other two wins over Nadal this year came on a hard court surface.
They had met on nine previous occasions on clay and Nadal had won every time.
In addition to his title in Madrid, Djokovic has won the Australian Open this year as well as in Dubai, Indian Wells, Miami and Belgrade.
Sunday's showdown took 2 hours, 18 minutes to finish and Nadal fought off one match point before falling. Djokovic converted 5-of-12 break chances in winning the 24th title of his career.
Nadal still has a 16-10 record against Djokovic. Nadal played in an ATP final for the 61st time and has a 45-16 record in those matches.