Offpinner Sachithra Senanayake had New Zealand's batsmen in a fuddle, removing McCullum and Kane Williamson in quick order and when Grant Elliott and Tom Latham went soon after, New Zealand were looking dicey at 101 for five.
However, Anderson batted positively, striking some thunderous boundaries before going lbw to Tillekaratne Dilshan within a couple of good blows of victory.
A fine century and a stunning late collapse provided contrasting highlights in Sri Lanka's 218 for nine.
Much of the innings was a battle for the Sri Lankan batsmen, but Mahela Jayawardene completed his 18th ODI century in fine style.
But he was the second of three wickets in a maiden over by left arm quick Mitchell McClenaghan in the 47th over.
McClenaghan had Jeevan Mendis caught at deep mid off, Jayawardene superbly caught at deep mid wicket by Anderson, running and diving to his left, before dangerous hitter Thisara Perera edged his first ball to be brilliantly caught by wicketkeeper Luke Ronchi leaping to his left.
Senanayake survived the hat-trick delivery.
Sri Lanka, who had won the toss, were slow early, experienced Dilshan fiddling about trying to find the pace of the pitch.
Kumar Sangakkara completed a miserable time in Christchurch - he got 6 and 1 in the first test two weeks ago - when he was caught at deep gully off speedster Milne for 4.
After finding his range, Jayawardene after finding his range, was rarely in trouble on his way to a run-a-ball century, which included 12 fours and a six.
There were occasional edges but his deft strokeplay ensured Sri Lanka at least had something to defend.
McClenaghan finished with four for 36 off his 10 overs, while Milne was impressive in taking two for 37. Nathan McCullum and Anderson picked up a wicket apiece while captain Angelo Mathews was run out for 15.
The second game in the seven-match series is in Hamilton on Thursday.
New Zealand: 219-7 in 43 overs (Corey Anderson 81, Brendon McCullum 51, Nathan McCullum 25 not out; Tillakaratne Dilshan 2-28, Sachithra Senanayake 2-43, Nuwan Kulasekara 2-43) def. Sri Lanka 218-9 in 50 overs (Mahela Jayawardene 104, Lahiru Thirimanne 23, Jeevan Mendis 23; Mitchell McClenaghan 4-36, Adam Milne 2-37).