Resuming on 57-5 and chasing a victory target of 350, a dogged maiden Test century from Moeen Ali and an extraordinary display of blocking from James Anderson, who survived 54 balls without scoring a run, looked to have salvaged an improbable draw, until bowler Shaminda Eranga struck.
Cook has not scored a Test century in 24 innings, in which time England have suffered an Ashes whitewash and now the ignominy of a first home series loss to Sri Lanka.
The opener said: “If I keep losing form and matches I won’t be asked to captain for much longer, but I’m determined to make it right.
“It’s a huge honour to captain England and I’m in it for the long haul, for as long as I can be, because I believe I’m the right man for the job.
“I never quit on anything. I’m a determined bloke and I’m determined to turn this around.”
A combination of resistance and rainfall saw England reach lunch without losing a wicket, but Joe Root (38) and Matt Prior (10) were dismissed before tea.
After Chris Jordan and Stuart Broad fell to Rangana Herath (3-59), England had 20 overs to cling on. Yet they managed to do so manfully until Anderson looped a short ball to Herath.