England won the second Test by nine wickets with more than a day to spare to go an unassailable 2-0 up in the three-match series.
Set 79 for victory after making Sri Lanka follow-on, England finished on 80 for one.
Left-handed opener Cook was 47 not out and Nick Compton, who hit the winning runs 22 not out.
His innings saw Cook score the five he needed to become just the 12th player of all time to make 10,000 Test runs.
More From This Section
Cook reached the landmark when he clipped Nuwan Pradeep for four through mid-wicket, having got off the mark with an edged single against left-arm spinner Rangana Herath.
At 31 years and 157 days he was the youngest player ever to achieve the feat, beating the previous record of India great Sachin Tendulkar (31 years and 326 days).
- Chandimal century -
=====================
Earlier, Dinesh Chandimal's excellent hundred kept England waiting as Sri Lanka made 475 in their second innings.
Chandimal's 126 was his sixth hundred in 27 Tests but first outside Asia.
Sri Lanka resumed on 309 for five, 88 runs adrift of England's 498 for nine declared built around Moeen Ali's Test-best 155 not out.
Chandimal was 54 not out overnight and Milinda Siriwardana unbeaten on 35 after Sri Lanka captain Angelo Mathews (80) and Kaushal Silva (60) initially kept England at bay.
Play began Monday under a heavily grey sky.
Siriwardana had not added a run to his overnight score when he edged Anderson straight to Alex Hales at gully to end a stand worth 92.
Chandimal, however, cover-drove Broad for four and late-cut Anderson behind point for another boundary.
Chandimal went into the 90s when he hooked fast bowler Steven Finn to the fine leg boundary.
An edged boundary off Woakes to third man saw the 26-year-old Chandimal to a 172-ball hundred including 11 fours.
Chandimal ended the session in style by cover-driving Woakes for four off the last ball before lunch.
Herath, dropped in the deep by James Vince off Anderson on 46, completed an 87-ball fifty with six fours.
Anderson, already England's all-time leading Test wicket-taker, then bowled Shaminda Eranga.
His return of five for 58 was the 21st time Anderson had taken five or more wickets in an innings his 115 Test-career.
Chandimal's more than five-hour innings ended when he was bowled driving at Stuart Broad.
But Sri Lanka's batsmen had at least restored some pride.
Their first innings 101 all out meant they became the first side since New Zealand in England back in 1958 to be bowled out for under 120 in three successive Test innings.
The third and final Test starts at Lord's on June 9.