Djokovic broke serve late in each set to get past the 20th-ranked Nishikori after nearly two hours in the Magic Box.
Djokovic hasn't made it to the quarterfinals in his previous five tournaments this year, admitting he returned to tennis too quickly. In his last event, he lost in the third round in Monte Carlo, where Nishikori reached the final.
Djokovic was aggressive from the start, hitting 26 winners against Nishikori, who has made at least the Madrid quarterfinals for the past five years. He was a finalist in 2014, losing to Rafael Nadal.
"The draw was such that we had to face in the first round, which is a bit strange,'' Djokovic said. "But it was a good opening match.''
Maria Sharapova, who won in Madrid in 2014, made it to the last 16 by defeating Irina-Camelia Begu 7-5, 6-1 in only her second match since the Australian Open. She has been dealing with a left forearm injury.
"It was a lot of hard work,'' Sharapova said of her match. "Being down a break to start off both of those sets didn't make things easy for me. That will certainly help me moving forward.''
"I was lucky to get away with it in that third set,'' the second-seeded Wozniacki said.
Milos Raonic defeated Nicolas Kicker 6-3, 6-2 to set up a second-round encounter with third-seeded Grigor Dimitrov, while Richard Gasquet beat Tomas Berdych 6-4, 6-2 to advance to play qualifier Dusan Lajovic, who got past Karen Khachanov 6-3, 6-2.
In a first-round match between Frenchmen, Benoit Paire hit 39 winners to defeat 18th-ranked Lucas Pouille 6-2, 6-3, advancing to face 19-year-old Denis Shapovalov of Canada, who got past Tennys Sandgren of the U.S. 6-1, 6-4.