Media playback is not supported on this device
Dinesh Chandimal made 126 and Rangana Herath 61 as Sri Lanka benefited from dropped catches at Chester-le-Street to move their overnight 309-5 to 475.
Anderson, the bowler to suffer from England's errors, returned to trap Herath lbw on the way to 5-58.
England then eased to a target of 79.
Cook reached his personal landmark five runs into an unbeaten 47.
The hosts, who have named an unchanged 12-man squad, will have the opportunity to complete a series whitewash in the third and final Test at Lord's, which begins on 9 June.
Sri Lanka were outplayed in both the first Test and the first half of this match, when they were shot out for scores of 91, 119 and 101.
But they should now have greater confidence travelling to Lord's, where conditions are likely to be much more suited to batting than Leeds and Durham.
Chandimal, unbeaten on 54 overnight, was fluent throughout, playing eye-catching strokes through the off side and heaving Moeen Ali for a six over mid-wicket.
His sixth Test century and first outside Asia was greeted by emotional celebrations, dropping his bat and kissing his helmet in a gesture towards the Sri Lanka dressing room.
He received spirited support from Herath, who grew in confidence during his second Test half-century, particularly when sweeping and reverse-sweeping Moeen.
However, that England were forced to field for longer in Sri Lanka's second innings than they had in the rest of the series combined was also down to their own mistakes in the field.
On a dark morning ideal for bowling, Anderson already had Milinda Siriwardana held at gully when he got Chandimal to inside-edge through to wicketkeeper Jonny Bairstow, who put down a straightforward chance to reprieve the right-hander on 69.
And Herath was given a life on 47 when James Vince made the mess of a skier, back-pedalling towards the point boundary.
Indeed, man-of-the-match Anderson aside, England were below their best with the ball, with Moeen and Steven Finn disappointing.
Media playback is not supported on this device
Still, Sri Lanka's stoicism did give the meagre Chester-le-Street crowd their opportunity for a moment of history, with captain Cook delivering.
Needing five to become the first Englishman to 10,000 Test runs, the left-hander inside-edged spinner Herath for a single, then clipped the pace of Nuwan Pradeep to the leg-side rope.
He becomes the 12th man in the history of Test cricket to reach the landmark and at 31 years, five months and five days, the youngest, beating the record of India legend Sachin Tendulkar, who was 31 years, 10 months and 20 days.
Cook lost opening partner Alex Hales, bowled by Siriwardana, but accumulated freely, in contrast to Nick Compton, who began tentatively.
Still, it was Compton who pulled Siriwardana for back-to-back boundaries to seal a four-day victory, the 11th consecutive Test in England that has failed to reach the fifth day.
England captain Alastair Cook: "It's hard for the Sri Lankan batters in one sense, but they are very good players, and most of the time on flat wickets you have to work very hard against them.
"Credit to Sri Lanka, the way they batted in the second innings, and it shows how hard you have to work for Test match wins. It was only two years ago that they beat us at Headingley, so we shouldn't take anything for granted."
Sri Lanka captain Angelo Mathews: "It's been a tough couple of weeks for us. We didn't bat well in the first innings but we showed a lot of resilience in the second innings. We had a brilliant first day but we let Moeen Ali and Chris Woakes off early on day two and our batting was a poor effort."
England coach Trevor Bayliss: "Any time you can win two Tests in a row and win a series, wrapping it up after two matches, is a fantastic effort. The wicket flattened out and the Sri Lankans showed some of the fight that they're quite capable of. They've got some very good players in their team. Yes, they've got some young players but we certainly can't take it for granted in the third match."
England ended Sri Lanka's resistance to win the second Test by nine wickets and complete a series victory - with captain Alastair Cook reaching 10,000 Test runs.