Leg-spinner Ish Sodhi claimed three wickets for 55 runs as the hosts reduced Sri Lanka to 128-7, before Perera took matters into his own hands with a flurry of big hitting en route to his maiden ton that ensured a thrilling end to the contest.
The 29-year-old gave New Zealand an almighty scare, smashing 13 sixes and eight boundaries in a 74-ball 140, before he became the final wicket to fall, dismissed by pace bowler Matt Henry.
Opener Danushka Gunathilaka was the only other Sri Lankan batsman to make a notable contribution, scoring 71.
New Zealand won the first match of the series at the same venue by 45 runs on Thursday, with the third and final contest taking place at Nelson on Tuesday.
(Reporting by Shrivathsa Sridhar in Bengaluru)