Williams, ranked 605th and turning 41 next month, won 7-6 (7-4) 2-6 6-2 to stun the Estonian in New York.
The American recently announced her intention to retire after her home major and is now into the third round.
Williams will play Australia's Ajla Tomljanovic next on Friday.
A few weeks ago, Williams announced she was "evolving away" from playing tennis in an essay for fashion magazine Vogue, but agreed after beating Montenegro's Danka Kovinic on Monday she had been vague about her exact timeline.
"There is no rush here," she laughed after beating Kontaveit. "There is still a little left in me."
While lacking some of the pomp and ceremony from her opening match on Monday, this was another special atmosphere as 23-time major singles champion Williams looked to extend her storied career by at least another round.
Read More (...)