The 63rd-ranked American winced with pain from a "messed up" back that forced her to leave the court for treatment but stunned the world number one with a barrage of forehand rockets to capture the second set and take a 2-1 lead in the third.
For a tormented Azarenka, it was a case of 'I'll have what she's having, please', as she waited in vain for the 23-year-old American to miss the lines on a sun-drenched Rod Laver Arena.
"She took a medical timeout but she rips winners all over the place. I was like 'can I have a back problem? I'm feeling great but I'm missing every shot!'" Azarenka said courtside after losing the match's winner count 41-17.
Hampton, a baseline pounder strong on both sides of the racket, has a history of back problems, and revealed she was suffering from two herniated (bulging) discs in her spinal column.
The affliction flared up at the French Open last year, leaving her unable to walk, and fears of a repeat at Melbourne Park were playing through her mind as she felt it start to pinch midway through the second set.
The pain made her try to shorten the points and go for broke against Azarenka. For nearly two sets the results were breathtaking.
"I was more focused on the cramping part of it because I have gone into a full-body cramp before. It's very painful. I was trying to manage that," the American said glumly.
"I didn't go into the match thinking that I was going to lose. I went in with a lot of belief."
The injury took the most toll on her serve, however, and she began to wilt in the deciding set after Azarenka broke back to level at 2-2.
Smelling blood, the statuesque Belarusian started crunching her returns and pushing for the corners to make the American run. "I think she surprised everybody a little bit today," said Azarenka, bidding for a second Grand Slam title.
"I had to really just step up my game and try to, you know, get the most rhythm as possible and try to make her move, try to execute my shots, try to be more aggressive myself."
The counter-attack propelled Azarenka to a 5-2 lead and she closed out the match in two hours and nine minutes with a withering backhand return.
Playing in her first third-round appearance at a Grand Slam, Hampton became the first to take a set off the top six seeds at the tournament so far, following a series of one-sided routs.
Azarenka will next play Russia's Elena Vesnina, who beat 16th seeded Italian Roberta Vinci. She said she felt she needed to improve "everything" about her game.
"These kind of matches sometimes... bring better things for you in the future, because winning ugly always means that you overcome something that you weren't feeling great, you weren't feeling all your shots," she added.
"So I take it as a positive in the end of the day."
American Serena Williams has had more than her share of dramas at this year's Australia Open but the third seed is planning to be all business like in the second week at Melbourne Park.
Williams, chasing her third straight singles grand slam title and 16th in all, rallied from 3-0 down in the second set to beat Japan's Ayumi Morita 6-1 6-3 in the third round.
So far in the tournament, Williams has turned her right ankle and hit herself in the head with her racquet.
"That's it, I'm done, I'm done," Williams said, when asked if she had any more surprises in store. "That was it. Just wanted to do two things. Now I got it out of the way."
On Saturday, the only damage she did was to her opponent, especially on serve, as she slammed down one delivery clocked at 207 kilometres an hour (128.6 mph).
That is just short of the record of 129 mph held by her sister, Venus.
"I wasn't going for it that hard," Williams said. "Every time I go for it, to hit it really hard, it goes in the 190s. When I hit the 207, I was like, 'OK, the first one wasn't luck, maybe I can hit a 207'. So it was pretty cool."
Williams said the right ankle she turned in her first round match was improving little by little but she was more pleased with her calmness on court.
"I think it was 2011 when I first came back (after a year out with illness and injury) and I played the summer hard courts," she said.
"I started playing really well. For whatever reason, I just started getting really calm. I didn't grunt as loud. I wasn't making as much noise. I just became really calm."
The five-time Australian Open champion now plays Russia's Maria Kirilenko for a place in the quarter-finals and though she has won all their previous encounters, she said she would be taking nothing for granted.
"Maria is playing consistent tennis, especially the past 16, 18 months, she's been so consistent," Williams said.
"My goal is just to be really focused against such a player that's doing so well. She beat me at the (US) Open in doubles (so) she's probably going to take that into consideration in the match."
Caroline Wozniacki will face Svetlana Kuznetsova in the fourth round after respective wins over Lesia Tsurenko and Carla Suarez Navarro.
The 10th-seeded Dane eased through in straight sets 6-4 6-3 against her Ukrainian opponent while Russian former US Open and French Open winner Kuznetsova needed three sets to overcome Spaniard Suarez Navarro 6-2 4-6 6-3.
Russian 14th seed Kirilenko downed Yanina Wickmayer of Belgium 7-6(4) 6-3 to book her place in the fourth round.