Hurkacz was pushed all the way by the Australian lucky loser Kokkinakis before emerging with a 6-7 (10/12), 7-6 (9/7), 7-6 (8/6) victory.
The Aussie had shown his mettle by saving six set points as he won the first-set tie-break and Hurkacz, the 2021 Miami champion, saved three match points in the second-set tie-break and another two in the final-set breaker.
"It’s tough to explain for me. I was just trying to stay in there and compete, play some good shots," said Hurkacz, the eighth seed at Hard Rock Stadium.
Kokkinakis was on serve at 6-4 up in the final set tie-break but Hurkacz produced a stunning winner up the line and that shot finally turned the tide decisively towards the Pole, who won the next three points to settle the contest.
The three hours, 31 minutes contest was the longest best-of-three ATP match of the year so far.
In contrast, Indian Wells runner-up Medvedev barely broke sweat beating Spanish clay-court specialist Roberto Carballes Baena 6-1, 6-2 in just 62 minutes.
The Russian's loss to Carlos Alcaraz in the Indian Wells final had ended his 19-match winning streak, but he was totally dominant as he struck 18 winners to the Carballes Baena's five.
Medvedev made use of the drop shot, which Alcaraz had used to good effect against him last week, and joked that he had been trying to emulate the world number one.
"I thought I needed to use that shot more. I've always liked drop shots but it's not a weapon in my game that I'm going to use 50 times a match," he said.
- Looking forward -
"You need to have confidence in the shot and today it worked pretty well," he said.
"I'm happy with my first match, solid performance, looking forward for next matches," he added.
Medvedev became the first player to reach 25 wins this season on either the ATP or WTA tours.
French players enjoyed upset wins with Quentin Halys saving three match points as he beat 18th ranked Australian Alex De Minaur 6-7 (5/7), 7-6 (7/3), 7-6 (10/8).
Gregoire Barrere, ranked 65th, beat Britain's 12th in the world Cameron Norrie 6-3, 6-2. The out of sorts Norrie received medical attention late in the second set.
Barrere will face Christopher Eubanks next after the American pulled off the biggest win of his career so far to beat 17th-ranked Croatian Borna Coric 6-3, 4-6, 6-2.
The 26-year-old Eubanks, ranked 119th in the world, recovered from a first set where the Croat looked in firm control to delight the home crowd.
Another American, Mackenzie McDonald won a thriller against 23rd-ranked Italian Matteo Berrettini, edging both tie-breaks and surviving two set points in the 12th game of the second set.
The home fans who stayed late were given a treat by rising star Francis Tiafoe who battled through an inspired performance from Japan's Yosuke Watanuki.
Tiafoe, the 12th seed, lost the first set on a tie-break before winning a second-set decider and then he finally establishing his dominance to win 6-7 (5/7), 7-6 (7/3), 6-4.
The 24-year-old Watanuki, ranked 123rd, used his powerful forehand to great effect, blasting 55 winners and peppering Tiafoe from the baseline.
“He was playing lights out and I was on the back foot a lot," said Tiafoe.
"He played a helluva match tonight, so give respect where respect is due. He was so red hot but I was hoping his level might drop in glimpses and I did a good job of taking advantage when it did," he added.
But there was disappointment for local favorite Ben Shelton who, despite playing some thrilling attacking shots, was beaten by the composed 34-year-old Frenchman Adrian Mannarino 6-4, 3-6, 6-1.
Czech Jiri Lehecka's impressive form continued as he took out 18th seed Lorenzo Musetti.
The 21-year-old, who reached his first Grand Slam quarter-final in Australia, triumphed 6-4, 6-4 to reach the third round of a Masters 1000 event for the first time.