The 11-time tournament champion looked ready to roll to a quick victory after dominating the first set, but Nishikori responded with some fine net play to level it at 1-1.
Nadal broke Nishikori twice in the decisive set, converting his second match point by driving a forehand winner down the line.
The top-seeded Nadal is still searching for his best tennis after being upset in the Monte Carlo quarterfinals by Andrey Rublev. He needed three sets to beat 111th-ranked Ilya Ivashka of Belarus in his first match in Barcelona on Wednesday.
"I didn't play a lot last year so I know that I will struggle,'' Nadal said. "I have been improving and I'm on the right path. I know the process. It doesn't happen overnight.''
Nishikori won the outdoor clay-court tournament in 2014 and 2015 when Nadal was battling injuries.
The tournament was not held last year because of the coronavirus pandemic.