The instinctive shot, when facing set point in the first-set tiebreak, helped Federer take the first set before he produced the match's first break in the second set and ran out a 7-6 (8/6), 7-5, 6-3 winner.
Afterwards, 6ft 10ins (2.08m) Croatian Karlovic, the tour's tallest player and with a world-record serve, said Federer had only a one in 100 chance to win the point after he dropped the ball close to the net, with the Swiss stranded.
But Federer, trailing 5-6 in the tiebreak, scrambled in and flipped a vertical lob over the towering Croatian, who could only parry it into his own court.
"Running up there, I didn't know what to do any more. Probably left and right, going to go too slow and he's going to slam it home," Federer recalled.
"Let me try the lob, even though that's not what you're supposed to do against him. I got sort of the angle right and was able maybe to surprise him, we're that close to each other, so it's hard to kind of react quick."
Karlovic was left shaking his head at the lob, which turned out to be the turning point in his 10th loss to the 16-time grand slam winner.
"I don't know. It's like one in a hundred that I'm going to lose that point. I don't know. It was really unlucky, you know," he said.
"I didn't really expect him to do that, but I was there. You know, I just, miscalculated (the) jump. It was really unlucky.
"Then, you know, if I would have won that, everything would have been different. But that is life, you know. Tennis, that's how it is."
The first set had gone with serve and Federer was unable to make inroads on the Karlovic delivery until the 12th game of the second set, when the rattled Croatian volleyed long to hand over the first break of the match.
And Federer broke early in the third set before closing it out in 2hr 17min to set up a fourth-round clash with either Bernard Tomic of Australia or Alexandr Dolgopolov of Ukraine.
"It's been a good match for me and a good last week or so," said Federer, who suffered back spasms during this month's Qatar Open.
"No back issues at all today. I didn't even think about it, to be honest. So it was a good day at the office."
Federer, 30, who came into the clash with a 9-1 head-to-head record against his 57th-ranked opponent, is bidding to become only the second man to win five Australian Open singles titles, after Roy Emerson.
The third seed has been without a grand slam title since he lifted the Australian Open in 2010.
Karlovic's record serve, at a Davis Cup tie in 2011, was measured at 251 kilometres per hour.
Federer finished 2011 on a 17-match winning streak after winning titles in Basel, Paris and the ATP World Tour Finals.