After more than three hours of fierce tennis, with both players diving and tumbling all over Centre Court, it all came down to a video replay on match point in the fourth set.
At 6-5 in the tiebreaker, top-seeded Djokovic hooked a sharply-angled forehand passing shot that was ruled wide. He challenged the call.
With both players and 15,000 fans watching anxiously, the replay was shown on the big screen and the verdict came in: The ball had landed on the line.
Point and match for Djokovic.
On a day when champions Andy Murray and Venus Williams won in straight sets, the late afternoon drama capped an entertaining battle that gave Djokovic a 6-4, 6-3, 6-7 (5), 7-6 (5) victory over the 35-year-old Czech veteran and a spot in the third round at the All England Club.
The two men, who have played each other a dozen times, shared a warm embrace as the crowd gave them a huge ovation.
''We know each other's game really well,'' said Djokovic, who extended his career record over Stepanek to 11-1. ''I was two sets up. I had some break-point chances in the third and should have closed it out in the third-set tiebreak.
''But credit to him for fighting. He's 35 years old and still moving very well and surface wise grass is probably his most preferred. He loves to engage the crowd. It was fun to be part of it.''
Djokovic, who won Wimbledon in 2011 and has seven Grand Slam titles, served 18 aces and had 54 winners. Stepanek, who fell to the turf numerous times, either slipping or diving or simply slumping from exhaustion, nearly matched him with 51 winners.
But Stepanek was never able to break serve, failing to convert on five chances. Djokovic broke only twice, once in each of the first two sets.
Murray, meanwhile, dropped just two games and needed only 81 minutes to blow away Blaz Rola of Slovenia 6-1, 6-1, 6-0, a dominant performance that showed he'll be tough to beat as he bids to become the first British player to retain the Wimbledon title in 78 years.
''If you can finish matches as quickly as possible it definitely helps in the long run,'' Murray said.
Five-time women's champion Venus Williams overcame a slow start to beat Japan's Kurumi Nara 7-6 (4), 6-1 to get past the second round of a major for only the second time in her last 10 Grand Slam tournaments.
''It's definitely a step in the right direction,'' Williams said. ''The thing that I just have to really work on is being on tour consistently and playing tournaments.''
The 30th-seeded Williams won six straight points in the tiebreaker after being down 1-4 and ran off six straight games in the second set to beat 41st-ranked Nara.
Next up for Williams is a third-round clash with 2011 champion Petra Kvitova, the Czech lefthander who downed Mona Barthel of Germany 6-2, 6-0.
''I think we both play similar games, really go for it,'' Williams said. ''She's one of the kind of players who can get kind of hot against me.''
No. 7 David Federer became the highest seeded men's player to go out so far. The Spanish clay-court specialist was beaten by Russia's 118th-ranked qualifier Andrey Kuznetsov, 6-7 (5), 6-0, 3-6, 6-3, 6-2.
The loss ended Ferrer's streak of reaching at least the third round at 17 consecutive Grand Slam tournaments. Kuznetsov, the boys' champion at Wimbledon in 2009, achieved his first win over a top-10 player.
In women's play, eighth-seeded Victoria Azarenka was eliminated by Serbia's Bojana Jovanovski, 6-3, 3-6, 7-5. Azarenka, a two-time Australian Open champion and former No. 1, was playing in just her second event since the Australian Open after being sidelined with a left foot injury.
Also advancing to the third round was second-seeded Australian Open champion Li Na, who beat Yvonne Meusburger of Austria 6-2, 6-2 on Court 2.
Fourth-seeded Agnieszka Radwanska of Poland needed less than an hour to beat Australia's Casey Dellacqua 6-4, 6-0.
The man who shocked Roger Federer at Wimbledon a year ago, Sergiy Stakhovsky, pulled off another surprise Wednesday. The 90th-ranked Ukrainian used the same serve-and-volley style that worked against Federer in 2013 to beat 12th-seeded Ernests Gulbis 6-4, 6-3, 7-6 (5).
No. 11 Grigor Dimitrov, coming of his win at the grass-court warm-up at Queen's Club, sailed into the third round by beating Australian qualifier Luke Saville 6-3, 6-2, 6-4.
For complete Wimbledon coverage, including updated draws and reports from Steve Tignor, head to our tournament page.