The Worcestershire all-rounder batted throughout the entirety of day five at Headingley to reach his maiden Test century, in only his second match, but James Anderson's dismissal on the penultimate ball snatched the Lions their first ever Test series win on English soil.
Cook had to field questions over his position as England captain following the 100-run defeat, but vowed to stay on and indicated that he has unearthed a future star of his team in the form of 27-year-old Ali.
The final pairing of Moeen and Anderson held out for 20 overs before England's number 11 was caught at leg gully off Shaminda Eranga, and Cook has hailed their resilience in a "gutting" losing cause.
"The way we fought there with the bat, Mo played an outstanding innings for a guy in his second Test match," he told Sky Sports News. "We knew we had to fight all day, pretty much shut up shop, and to get 100 like that is a great effort and bodes incredibly well for the future.
"We knew his class, you never know how a guy's going to adapt to international cricket but the way he's handled himself in the last two games, he's a brilliant cricketer in the way he constructed that innings today and he doesn't deserve to be on the losing side.
"The last three wickets, hanging in like that. We thought we were getting closer and closer and you're believing as well. Jimmy to survive, I think 80 minutes up there, was a great effort, gutting to come up short. Credit to Sri Lanka for the way they kept going today, the series was very close and they've just won the crucial moments."