In reply to Australia’s formidable 559 for nine declared on a placid wicket, the Kiwis were 406 for three at tea, still trailing by 153 runs but looking well-placed to at least save the match.
Taylor had emerged from a form slump and was 165 not out, with captain Brendon McCullum on 21.
Williamson made 166, his second century in as many matches, before mistiming a pull shot from the bowling of Josh Hazlewood and being caught at mid-on by Mitchell Johnson to end a record 265-run stand with Taylor, a new benchmark for New Zealand in Tests against Australia.
He faced 249 balls in 390 minutes and hit 24 boundaries.
The 25-year-old made 140 and 59 in the first Test at the Gabba, which New Zealand lost by 208 runs, and continued that form in Perth.
It was his 12th Test century and only three other players have scored as many centuries at the same age – Sachin Tendulkar (16), Don Bradman (13) and Alastair Cook (12).
Williamson has made centuries in five of his last seven Tests, against Pakistan, Sri Lanka, England and Australia, and in that time he has scored 1118 runs at 111.80.
Taylor was a little less sure at the crease and flirted with disaster on a couple of occasions, but managed to post his 13th Test hundred.
It was a welcome milestone for the classy Taylor, who has been struggling with his form for some time and had not scored a Test century since November last year.
He had faced 213 balls and hit 26 boundaries.
Australian paceman Mitchell Starc gave the home crowd something to cheer about when sent down a 160.4 kph (99.7 mph) delivery to Taylor before tea.
It was the fourth fastest delivery ever recorded, with Pakistan’s Shoaib Akhtar holding the record with 161.3 kph.
Australia did not help their own cause with some missed catches, including a lifeline for McCullum when he was on five.