Williamson, who had resumed after the break at Seddon Park on 39, quickly moved through to his 12th Test half-century by attacking Veerasammy Permaul and Tino Best before he was bowled by Permaul with six runs required for victory.
The hosts finished on 124-2 with Hamish Rutherford unbeaten on 48 and Ross Taylor on two.
The hosts finished on 124-2 with Hamish Rutherford unbeaten on 48 and Ross Taylor on two.