New Zealand, battling to square the series in the deciding Test, were 209 for one, 105 behind South Africa's first innings 314 and with nine wickets in hand.
Williamson was on 80 and required a further 20 runs to equal Martin Crowe's New Zealand record of 17 centuries, while Raval was on 75, his third half century from four innings in the series.
After an early set back with the loss of Tom Latham seven overs into the day, Williamson and Raval put on 126 for the second wicket.
He took 110 innings to reach the milestone, seven fewer than the previous best of 117 by Crowe.
More From This Section
After rain delayed the start of play, New Zealand added 65 in 22 overs available before lunch and another 77 in a full two hours through to tea as further forecast bad weather held off and the pitch flattened out.
But, with just over two days remaining, New Zealand need to score quicker than that if they are to have any chance of squaring the series in the rain-disrupted Test.
This time the edge was off Morne Morkel with Quinton de Kock diving to his left to take the catch one-handed.
Raval, who resumed the day on 25, carefully gathered ones and twos as he stymied South African quicks Morkel, Philander and Kagiso Rabada while Williamson chased runs wherever he could get them.
After going into this Test with only nine Test sixes to his credit, he has cracked two in this innings -- one off Philander and the other a booming drive over spinner Keshav Maharaj's head.
His fielders had been roughing it up with one-bounce throws to encourage reverse swing.
With the first delivery he faced from the replacement ball, Williamson drove Maharaj off the back foot for three to bring up his 26th half century.