The Black Caps, set a revised Duckworth-Lewis target of 198 in 23 overs, replied with 203-6 as McCullum hit spinner Rangana Herath for three sixes and a four to seal a last-ball win.
The victory was set up by a superb 86 off 68 balls from opener Tom Latham and a quickfire 49 by Luke Ronchi, the pair adding 93 from 57 deliveries for the fifth wicket.
Both batsmen fell in the 21st over bowled by Nuwan Kulasekara, but McCullum steered the Black Caps home with an unbeaten 32 off nine balls.
Latham's knock contained 12 boundaries and a six, while Ronchi hit seven fours and a six. Earlier, Sri Lanka made 138-1 from 23 overs in between a rain interruption of more than four hours.
Sri Lanka, who won the toss and elected to bat, were 117-1 in 20.4 overs when bad weather hit the southern coastal town. When the game resumed, it was curtailed to 23 overs which allowed Sri Lanka to add a further 21 runs in the remaining 14 deliveries.
Tillakaratne Dilshan scored 55 not out and Kumar Sangakkara hit an unbeaten 71 off 59 balls, the duo adding 126 for the unbroken second wicket after opener Dimuth Karunaratne was dismissed for four.
New Zealand's reply began on the wrong foot when Kulasekara dismissed Anton Devcich and Rob Nicol off successive balls in the second over.
Both batsmen fell to catches behind the stumps by wicket-keeper Sangakkara, who also stumped Grant Elliott off Sachithra Senanayake to reduce the Black Caps to 34-3.
Kulasekara finished with four for 34 and Senanayake took two for 31. The first match on Sunday at the same venue was rained out with New Zealand on 13-1 in 4.2 overs in reply to the home team's 288-9.
The third and final one-dayer in Dambulla on November 16 will be followed by two Twenty20 internationals in Pallekele on Nov 19 and 21. No Tests are scheduled on the short tour.