Stephens, playing in only her seventh grand slam event, took full advantage as Williams injured her back and then lost her temper.
Stephens, the No 29 seed, showed no nerves facing her idol as she recovered from dropping the first set to win 3-6 7-5 6-4.
Williams, a winner in Melbourne in 2003, 2005, 2007, 2009 and 2010, needed a medical time out during the second set - while she was warned in the decider after smashing her racquet.
The frustration appeared to come from the fact that Williams had seemingly been on course for a straightforward win over her fellow American after taking the first set fairly comfortably.
Stephens had other ideas, though, as she broke in the eighth game of the second set to move 5-3 up. However she blotted her copybook by wasting a set-point chance, with Williams breaking back.
Williams, though, hurt herself in the process - and Stephens took advantage as she broke again to finally level the match.
Stephens again had to show her fighting qualities in the decider as Williams broke in the seventh only for her rival to respond immediately.
Stephens saved a break point in the ninth and then sealed an amazing win as Williams dropped her serve at a crucial time.