South Africa twice dropped chances off Liton during the most productive partnership of the innings.
Although there was no extravagant turn off a slow surface, South Africa's spinners bowled 78 of the 115.
It did not seem likely to be a long day for South Africa when nightwatchman Taskin Ahmed was caught at gully off Williams with only three runs added to the overnight total of 98-4.