Dinesh Chandimal’s 126 led the Sri Lanka resistance which left England needing to bat again after all to complete a nine-wicket, rather than innings, win and take an unassailable 2-0 lead.
It was a comforting and historic by-product that Cook - after falling short at Headingley last week and then again in the first innings here - could take an unexpected opportunity to reach five figures as England knocked off the 79 runs required.
They got the job done in the hour after tea - for the loss of only Alex Hales, bowled off his pads by Milinda Siriwardana - with Cook unbeaten on 47, after others had conspired to set the captain’s stage.
Chandimal was primarily responsible - while for England James Anderson recorded his third five-wicket haul of the series, in the process taking his own remarkable career aggregate past 450.
England resumed in pursuit of five wickets for under 88 to avoid the bother of putting their pads on a second time.
Eventually, though, Anderson (5-58) was to the fore as Sri Lanka were bowled out for 475 - having followed on 397 behind.
Anderson parted Chandimal and Siriwardana in the fifth over of yet another grey morning, but England could not strike again before lunch as Rangana Herath (61) proved another sturdy ally for Sri Lanka’s centurion.
Angelo Mathews’ team could therefore be encouraged by an improvement at least on last week’s innings trouncing, albeit the series about to be lost with a match to spare.
The home attack struggled, for the first time, for much of Sunday - and so it was again, even after Anderson got them up and running by ending the sixth-wicket stand on 92.
Siriwardana did not add to his overnight 35 before trying to drive on the up and getting a thick edge to gully.
In his next over, Anderson’s milestone wicket ought to have been the big one of Chandimal on 69 - but Jonny Bairstow failed to hold an inside-edge.
The missed chance brought no long-term consequence but plenty of transient exasperation as, instead of being 325-7, the tourists ploughed on - and Chandimal reached his 172-ball hundred when he deflected Chris Woakes to third man for his 11th four.
His protracted celebrations of a first century outside Asia included taking off most of his protective equipment, and kissing the national badge on his helmet.
England had few other opportunities to disturb Chandimal or Herath before lunch - although the latter would have been run out for just a single scampering a second run for his partner, had Steven Finn’s throw from the deep happened to be a direct hit.
The only century stand of the match came up on another bum note for England in early afternoon, James Vince appropriately ending up on his backside as he mis-judged and dropped a very awkward, swirling skier when Herath went after a cut at Anderson.
Herath’s next scoring shot was a single for just his second Test half-century, from 111 balls, but Anderson got his man at last - and his 450 - when he pinned the stocky left-hander lbw from round the wicket.
Anderson then knocked out Shaminda Eranga’s off-stump, to take his series haul to 18 wickets, and Stuart Broad returned to dislodge Chandimal’s off bail when he missed an attempted big hit.
His rearguard had lasted more than five hours, and England’s even longer wait was over too after one more brief instalment of aggravation in a stand of 22 between numbers 10 and 11.
Cook soon added to England’s well-being, clipping the sixth ball he faced to the midwicket boundary off Nuwan Pradeep for his milestone.
He is the first Englishman to reach it, and the world’s youngest batsman to do so.
A sparse crowd of little more than 2,500 was witness, having initially assembled in unwelcoming weather with no reasonable expectation of seeing Cook’s piece of history.
For that, they had Chandimal to thank.