Kokkinakis has struggled badly with injury in recent years and needed a wildcard to play at the US Open this year.
But the Australian rewarded the tournament organisers’ faith by beating Ilya Ivashka 6-3 7-6 6-7 6-2.
It was Kokkinakis’ first win at a Grand Slam event in more than four years.
And the 24-year-old will now meet Nadal for a place in the third round.
Nadal made light work of Kokkinakis’ compatriot John Millman in the first round on Arthur Ashe Stadium.
The Spaniard outclassed Millman, who beat Roger Federer last year, 6-3 6-2 6-2 in just over two hours.
Afterward, Nadal was asked about the prospect of playing Kokkinakis and the second seed said the Aussie has the weapons to cause him problems.
“Yeah, he’s young. He has a big forehand, big serve. He’s a dangerous opponent, of course,” he said.
I need to go on court and to play well. If not, will be a very difficult match. So let’s see. I think I had more or less positive feelings tonight. I need to keep improving every single day.
“Winning with that result allow me more to have a good practice. I hope to be ready for after tomorrow knowing is a tough challenge, Thanasi in the second round.”
Nadal’s half of the draw saw four top ten seeds crash out on Tuesday and the 18-time Grand Slam champion expressed his surprise at the demise of Dominic Thiem, Stefanos Tsitsipas, Karen Khachanov and Roberto Bautista Agut.