The 25-year-old Ukrainian had lost his previous five matches against Nadal, including the final of the Rio Open last month, but Dolgopolov's incessant energy got the better of his Spanish opponent at Indian Wells with the world number 31 winning 6-3 3-6 7-6 (7-5).
Up 6-5 in the third-set tie-break, Dolgopolov was denied the opportunity to win with an ace, with Nadal's challenge showing the serve was out by millimetres.
But the Ukrainian 28th seed recovered and clinched victory with his second serve, pounding the world's leading male player with successive forehands before one beat Nadal and wrapped up the match.
The match started in strange fashion with the opening four games going the way of the returnee.
Dolgopolov then broke Nadal for the third time in the eighth game before serving out the first set.
Nadal claimed the second set's decisive break of serve in the sixth game to level the match after one hour and 19 minutes.
In a topsy-turvy third set, Dolgopolov led 5-2 but lost the next three games before both players held serve once more to force a tie-break.
Dolgopolov served first and, as was typical throughout the match, attacked when given the opportunity but failed to convert his volley.
At 2-2 in the tie-break, Dolgopolov pushed a cross-court backhand long before Nadal produced a strong serve and crunched his opponent's short return away to lead 4-2.
Dolgopolov won the next three points before Nadal levelled at 5-5.
The world number one then looked certain to claim the first match point opportunity when his serve forced Dolgopolov wide but Nadal poked his second shot long on the half-volley.
The Ukrainian looked to have won the match with his 12th ace of the match but Nadal's challenge forced Dolgopolov to serve again, although it did not keep the Spaniard alive for long.
Dolgopolov's high energy and attacking focus was underlined by 36 winners and 49 unforced errors compared to Nadal's 17 and 23 respectively.
Italian Fabio Fognini will be Dolgopolov's next opponent at the ATP 1000 event after the 13th seed defeated France's Gael Monfils 6-2 3-6 7-5.
Swiss third seed Stanislas Wawrinka cruised into the next round with a 6-0 6-2 demolition of Andreas Seppi of Italy.
The Australian Open champion will face South Africa's 17th seed Kevin Anderson, who defeated Russian Evgeny Donskoy 4-6 6-0 6-3.
Roger Federer joined countryman Wawrinka in the fourth round with a hard-fought 7-6 (9-7) 7-6 (7-2) win over Russian 27th seed Dmitry Tursunov.
Great Britain's Andy Murray - the fifth seed - recovered from dropping his first set against Jiri Vesely to win 6-7 (2-7) 6-4 6-4, while Canadian 10th seed Milos Raonic overcame Alejandro Falla of Colombia 6-4 6-3.