New Zealand needed another 32 runs to win from 126 balls.
Williamson struck four boundaries during his stay at the crease.
New Zealand were in a comfortable position during their chase of the 187-run target set by Afghanistan.
Najibullah Zadran and Samiullah Shenwari scored fifties to guide their side from a tough spot.
Najibullah Zadran was caught by Daniel Vettori off the bowling of Adam Milne.
Afghanistan earlier elected to bat, with neither team announcing any change for the match.
Mohammad Nabi and Asfar Zazai were the Afghanistan batsmen removed in the 20th over.
Vettori achieved the milestone when he bowled Nawroz Mangal for a score of 27 off 46 balls.
Javed Ahmadi, Usman Ghani and Asghar Stanikzai were sent back to the pavilion with single-digit scores.
New Zealand will be expected to steamroll the inexperienced Afghanistan side.