In an absorbing match, the 23-time Grand Slam winner was outmuscled by the Kazakh, who will now seek to take advantage of an open women's draw.
The American tried to lift her level but instead became the latest top-10 seed to depart the women's singles.
Her next chance to equal Margaret Court's record of 24 Grand Slam singles titles comes at Wimbledon from 28 June.
"It was definitely close," Williams said. "There is literally a point here, a point there, that could change the whole course of the match.