Williamson brought up his half-century to continue his fine form in 2015, recording the 17th fifty of his Test career.
The hosts edged past the 200-run mark to extend their lead, but Williamson was to fall for 71, ending his 141-run partnership with Latham.
However, the opener was not deterred by the loss of Williamson as he powered on and notched the third Test century of his career as the Kiwis upped their run-rate.
Ross Taylor departed for a quick-fire 15, while Brendon McCullum blasted two sixes in his brief innings before the skipper opted to declare on 267-3, leaving Sri Lanka to chase 405 runs to win the game.
However, Southee returned to the attack to dismiss Karunaratne for 29 when he was caught behind by BJ Watling, while Neil Wagner then removed Udara Jayasundera.
Mendis continued to thwart the Kiwis with his stoic strokeplay along with Dinesh Chandimal, but the opener was to fall four runs short of his half-century when he edged behind a delivery from Southee into the gloves of Watling.
Immediately after the Mendis's dismissal, hail thrashed down at the University Oval bringing a premature end to the fourth day.
Sri Lanka require another 256 runs to win the match, while New Zealand need just seven wickets on the final day.