Serving to stay in the set, Williams double faulted then netted a crosscourt backhand to trail 0-40 and face three setpoints.
Keys struck a down the line forehand return winner to break serve and take the set.
The 19 year old Keys then held serve following three Williams baseline errors to take her fifth game in a row as she lead 6-3, 1-0 after Williams had first led earlier in the match 3-2.
After hitting with more consistency and power, Williams took the next four games of the match to lead 4-1 in set two before Keys took an injury timeout.
After returning to the court with her left thigh wrapped, Keys won three games in a row to level the set at 4 games all.
However more baseline pressure from Williams resulted in another break of serve as she led 5-4.
Serving for the set, Williams went ahead 40-15 following three forehand errors from Keys.
Williams then struck an ace down the tee to hold serve and level the match at one set all.
Keys held serve to start the final set before Williams won three games in a row to lead 3-1.
Keys then held serve to pull to 3-2.
Serving at deuce, Williams struck two unforced forehand errors to drop serve and level the set at 3 games all.
With Keys serving at 30-40, Williams struck a forehand down the line winner to break serve and lead 4-3.
However Keys then hit several powerful forehands to put Williams on the run to reach 30-40 on Williams’ serve.
Keys broke serve with a crosscourt forehand winner to level the set at 4 games all.
With Keys serving, two Williams backhand down the line errors put Keys ahead 30-15. Keys then struck a backhand down the line winner followed by an ace out wide to hold serve and lead 5-4.
Serving to stay in the match, Williams netted a crosscourt forehand then netted a crosscourt backhand to trail 0-30.
A Keys forehand down the line winner put the younger American ahead triple match point.
Williams, who had led 3-1 and 4-3 in the final set, netted a crosscourt forehand to end the match.