Sri Lanka were unable to capitalise on the bowler-friendly conditions as Guptill batted through the first two sessions unbeaten on 111, his third Test century.
The confident Williamson was nearing his 13th Test century when he fell last ball before tea. After looking assured for 123 deliveries he slashed at a short, wide delivery from Nuwan Pradeep and was caught at second slip. It was an uncharacteristic error of judgement from Williamson who fell eight runs short of becoming the fifth batsman to post 1,000 runs in 2015.
For Guptill, it was a return to form after he struggled for runs in New Zealand's recent series against Australia where he averaged a shade over 13. Against a more lenient Sri Lankan attack he was more comfortable, assisted by an ounce of luck when twice the target of lbw appeals by Dushmantha Chameera.
Sri Lanka unsuccessfully reviewed the first decision but accepted the second when replays showed a review might have been successful.
But the chances offered by Guptill, including two shaky edges and a near run out, were few as he displayed confidence, particularly on the front foot. In an innings filled with elegant off-drives, it was fitting Guptill reproduced his favourite stroke to bring up his century when he drove Suranga Lakmal to the boundary. It was the first time he has reached three figures in 41 innings since his last century, 109 against Zimbabwe four years ago.
Sri Lankan captain Angelo Mathews elected to bowl first on the green-tinged wicket but his seamers were unable to put pressure on the batsmen.
Guptill and Tom Latham put on 56 for the first wicket before Latham, on 22, offered Lakmal a simple caught and bowled chance. It brought Williamson to the middle to join Guptill in a record New Zealand second wicket stand of 173 against Sri Lanka.
With his seamers lacking penetration, Mathews turned to his bowling kingpin Rangana Herath for nine overs after lunch, which ceded a miserly 21 runs.
However, the batsmen were never seriously threatened with the wicket still a few days away from taking noticeable turn.
Test debutant Udara Jayasundera also rolled his arm over before the tea break. For Sri Lanka, Lakmal has one for 58 and Pradeep one for 63.(AFP)