The world number 100, making his Wimbledon debut, overpowered the Spanish second seed who was seeking his third title at the All England Club with an inspired display on Centre Court.
"I never expected something like this," Rosol said. "I am very sorry for him but I hope I can play one more match like this. I played my best match ever. It means so much for me."
Nadal looked on course to reach the third round in routine fashion when he came through a marathon first-set tiebreak 11-9.
But Rosol, who has never gone beyond the third round of a grand slam, broke serve in the opening game of the second set and stunned Nadal with a succession of inspired winners from all over the court.
Nadal was powerless to stem the tide and was clearly upset by the 26-year-old Czech's aggressive style but he dug in to break serve at the start of the fourth set and repeated the feat to level at two sets all.
Officials decided to close the Centre Court roof to enable the match to be finished.
After a half-hour delay the players returned and Rosol immediately broke Nadal's serve.
He continued to subject the world number two to a barrage of aces and outrageous winners to set up a third-round match against German Philipp Kohlschreiber.
It was the first time Nadal had lost before the third round of a grand slam since he was beaten by Gilles Mueller in the second round at Wimbledon in 2005.