After the biggest victory of her life, the 19-year-old Stephens is headed to the semifinals of the Australian Open.
Williams hurt her back in the eighth game of the second set, slowing down her serve, restricting her movement and causing her obvious pain.
Stephens kept her composure, blocking out the injury issue on the opposite side of the net, and rallied for a 3-6, 7-5, 6-4 victory on Wednesday -- by far the most significant in her seven Grand Slams.
The gravity of it didn't hit Stephens until she was warming down, and even then the victory had an unreal feeling.
"I was stretching, and I was like, 'I'm in the semis of a Grand Slam.' I was like, 'Whoa. It wasn't as hard as I thought.' But it's pretty cool," she said. "To be in the semis of a Grand Slam is definitely I say a good accomplishment. A lot of hard work."
It was Williams' first loss since Aug. 17, ending a run of 20 consecutive wins.
The 15-time major winner hadn't lost a match at a Grand Slam tournament since the French Open, where her first-round exit sparked her resurgence in the second half of 2012 that included titles at Wimbledon, the London Olympics, the U.S. Open and the WTA Championship.
After winning her first Grand Slam quarterfinal, Stephens next plays defending champion Victoria Azarenka.
The No. 29-seeded Stephens had been given barely a chance of beating Williams, who lost only four matches in 2012 and was in contention to regain the No. 1 ranking at the age of 31.
Williams' latest winning streak included a straight-sets win over Stephens at the Brisbane International earlier this month.
And Stephens wasn't even sure that she could beat Williams, until she woke up Wednesday.
"When I got up, I was like, 'Look, Dude, like, you can do this.' Like, 'Go out and play and do your best,' " she said.
It wasn't until after losing the first set and being broken in the first game of the second that she really convinced herself she could.
"I was like, 'Hmm, this is not the way you want it to happen. But you just fight and just get every ball back, run every ball down, and just get a lot of balls in play, I think you'll be OK.'
"From then on I got aggressive, started coming to the net more, and just got a lot more comfortable."
She started hitting winners, cutting down on the errors, and pushing the injured Williams around the court.
Williams walked around the net to congratulate Stephens, who then clapped her hand on her racket and waved to the crowd, a look of disbelief on her face.
She then went to her tennis bag, pulled out her phone and started checking for any text messages from her mother.
"I was hoping she had texted me right away. I thought maybe she was texting me during the match," Stephens said. "I'm sure my grandparents are like freaking out."
Stephens has said she had a photo of Williams up in her room when she was a child, and had long admired the Williams sisters.
"This is so crazy. Oh my goodness," Stephens said, wiping away tears in her post-match TV interview. "I think I'll put a poster of myself (up) now."
For her part, Williams said the bad back was just another problem to contend with at a Grand Slam event that had been "absolutely" her worst for injuries. It started when she injured her ankle in the first round.
"I'm almost relieved that it's over because there's only so much I felt I could do," she said. "It's been a little difficult. I've been thrown a lot of (curve) balls these two weeks."
Williams was up a set and a break before Stephens settled in. In the eighth game of the second set, Williams was chasing a drop shot to the net when she appeared to hurt her back. She needed a medical timeout after the set, and then slowly started to regain the speed in her serve.
She said her back "just locked up" on her.
"I couldn't really rotate after that," she said. "It was a little painful, but it's OK."
There were times when she barely concealed the pain, and had to bend over or stretch out her back. Yet the thought of retiring from the match only crossed her mind "for a nanosecond."
It didn't mean she wasn't frustrated. Williams smashed her racket into the court in the third set, breaking the frame and then flinging it toward the chairs on the side of the court. She looked to the sky occasionally and yelled at herself.
The racket abuse cost her $1,500 in fines.
Azarenka, with her most famous fan sitting in the crowd wearing a shirt reminding her to keep calm, overcame some early jitters to beat Svetlana Kuznetsova 7-5, 6-1 in the earlier quarterfinal at Rod Laver Arena.
After dropping serve in a long fourth game that went to deuce 10 times, Azarenka recovered to dominate the rest of the match against Kuznetsova, a two-time major winner who was floating dangerously in the draw with a No. 75 ranking as she recovers from a knee injury.
Azarenka's American rapper friend, Redfoo, returned from a concert in Malaysia to attend Wednesday's quarterfinal.
Wearing a red sleeveless T-shirt that read "Keep Calm and Bring Out the Bottles," the name of his next single, Redfoo stood, clapped and yelled "Come on, Vika!" during the tight first set.
Asked if it helped to have her No. 1 fan wearing a keep calm logo, Azarenka said "I was looking more at the part that says 'Bring out the bottles.' "
Of her game, she added, "I'm just glad I could produce my good tennis when it was needed."
Williams' loss was a boost for Azarenka, who lost all five head-to-heads against the American in 2012 and is 1-11 in their career meetings.
Information from The Associated Press was used in this report.