Sent in to bat first, Sri Lanka posted a challenging target of 317-6, helped by an aggressive 88 from opener Tillakaratne Dilshan and half centuries from Kusal Perera (59) and Mahela Jayawardene (55).
England was bowled out for 292 in the 48th over with Ali at the heart of the reply with his maiden century in ODIs. His innings included five sixes and 11 boundaries but lacked support from the other batsmen, with the exception of Ravi Bopara who was out last for 65.
Cook was beaten by deliveries swinging in, was hit on the pad and given out by Sri Lankan umpire Ruchira Palliyaguruge. But television replays showed that the ball hit the pad high and could be bouncing over the wicket.
However Cook was not third time lucky when offspinner Dilshan trapped him lbw for 10 runs for England's first wicket with the total on 51.
Also Read
A flurry of wickets soon left England reeling on 159 for five. Some hope returned for the tourists in a 44-run stand for the sixth wicket between Ali and Bopara, followed by 40 runs for the seventh wicket between Bopara and Ben Stokes. Ali was the fifth wicket to fall, caught and bowled by leg spinner Jeevan Mendis.
England always appeared to have a chance but lost wickets at crucial moments.
Thisara Perera had figures 3-44 and was supported by spinners Ajantha Mendis (2-55) and Herath (2-58).
No. 3 Kumar Sangakkara was out lbw for 2 after being beaten by flight and turn from offspinner Ali.
Jayawardene rebuilt the innings with Dilshan with a 76-run third-wicket stand in 81 balls.
Dilshan was beaten by a slower ball from seamer Chris Woakes, and gave him a return catch. He hit 10 boundaries for his 40th half-century.