The Queenstown crowd erupted in celebration as number 11 batsman Michael Mason found the boundary with a lofted drive off the last ball of the match on Sunday.
Mason had been unable to score from any of the preceding five balls of the final over from spinner Sanath Jayasuriya.
But it was coolheaded Franklin who had put New Zealand in the position for victory with 45 crucial runs in the final overs and he had some valuable advice for his team mate before he faced the last ball.
"I just said to him whack the crap out of that last one, and he did," Franklin said later.
Sri Lankan skipper Mahela Jayawardene described Franklin's innings as the difference between the two teams Sunday and said his team had needed to score 15 to 20 runs more to set a decent target for New Zealand.
The victory levelled the series 1-1 with three matches to play after New Zealand scored 228-9 in their 50 overs in reply to Sri Lanka's 224-7.
The home side was always on the pace in terms of the required run rate but wickets fell regularly, leaving the tail-enders with the task of finishing the job. Sri Lanka appeared to be in the box seat by the 38th over when New Zealand had been reduced to 175-7.
But Franklin kept his head along with the other tail-enders, especially number 10 Mark Gillespie (11), who successfully fended off a series of high speed yorkers from Sri Lankan paceman Lasith Malinga.
New Zealand appeared to be cruising to victory earlier but the introduction of super spinner Muttiah Muralitharan, who took 3-31 off his 10 overs, ensured the result continued to hang in the balance.
Makeshift opener James Marshall, who came into the match with a one-day international average of only five, gradually found his confidence to topscore for New Zealand with 50.
But his repeated risk-taking with quick singles cost his own wicket when he ran himself out just after reaching his half century.
A mix-up between Marshall and Ross Taylor (15) had earlier seen Taylor -- who made a century in the first international -- run out just as the New Zealand innings was starting to take off.
Sri Lanka found themselves up against a much-improved New Zealand bowling attack Sunday after plundering 286-3 in 40 overs to ensure a win in the opening match on Thursday.
Only a quick 34 runs from Farveez Maharoof and Chaminda Vaas in the last three overs ensured a respectable total.
Master batsman Kumar Sangakkara topscored with 89, and appeared set for a century before being unluckily run out at the non-striker's end when bowler Andre Adams deflected a straight drive from Chamara Silva on to the stumps.
Sangakkara finished with 89 from his 122-ball innings, including 10 fours, after bringing up his 35th one-day international 50.
Silva chipped in with 31, with other contributions from Upul Tharanga (23), Marvan Atapattu (22) and Maharoof (29 not out).
Skipper Daniel Vettori was again the stingiest of the New Zealand bowlers, taking 1-37 from his 10 overs. Pace bowlers Gillespie with 2-46 and Mason (2-50) redeemed themselves after taking a thrashing at Napier.