England needed to win to make the last four from Group 1 alongside already qualified New Zealand and they achieved the feat in a nail-biting finish with two balls to spare at Sydney Cricket Ground (SCG).
If they had lost, hosts Australia would have gone through.
Sri Lanka looked on track for a big total when they reached 80-2 after 10 overs but the aggressive Pathum Nissanka was out for 67 and the Asian champions crumbled to 141-8, with Mark Wood taking 3-26.
England raced to 75 without loss in reply and looked on track for an easy win. However, they collapsed to 111-5 under pressure from the Sri Lankan spin attack and it went to the wire.
“Didn’t enjoy that match, how close it was,” admitted skipper Jos Buttler.
“We just had to find a way to win that game,” he added.
He further said, “These situations are built for him [Stokes]. He can play a lot of roles for us in this T20 setup.”
Man-of-the-match Adil Rashid, whose spin kept Sri Lanka’s batsmen at bay, was also full of praise for Test skipper Stokes.
“It was a tight game, it happens in T20 cricket,” he said. “They bowled well and created pressure but Stokes played magnificent so we got over the line,” Rashid added.
The victory was not enough to dethrone New Zealand at the top of the table with England settling for second and a semi-final in Adelaide. The fate of Group 2 will be determined on Sunday.
Sri Lanka’s defeat ended Australia’s stuttering tournament, with their title defence never recovering after losing heavily to New Zealand on the opening day, then having to share the points with England due to rain.
“I think the wicket played a part in this game, even the English batters struggled in the second half,” said Sri Lanka captain Dasun Shanaka.
“I think we played good cricket in patches but we had a few injuries which cost us the tournament,” he said.
Sri Lanka — who have not beaten England in a T20 since 2014 — won the toss and asked England to field, conscious that all five previous games at the SCG during the World Cup had been won by the team batting first.
Nissanka pulled Stokes for an authoritative six off the second ball and two more sixes in the third over — off Wood — signalled their intent.
However, the aggressive 39-run opening stand came to an end when Kusal Mendis (18) attempted another boundary from Chris Woakes and Liam Livingstone held a catch near the ropes.
Nissanka kept the runs flowing but his new partner Dhananjaya de Silva (9) slogged at a slower Sam Curran ball and was caught by Stokes.
Sri Lanka reached 80-2 at the halfway point but then, Livingstone took a simple catch to remove Charith Asalanka (8).
Nissanka brought up his second 50 of the tournament and ninth overall, but tight bowling from Rashid slowed the run rate and he eventually accounted for Nissanka, who heaved to substitute fielder Chris Jordan at long-on after a 45-ball knock.
Sri Lanka never regained momentum, making just 25 off the last five overs.
In reply, Alex Hales and Buttler plundered 70 off the six-over powerplay, smashing 11 boundaries in the process.
Sri Lanka gave themselves hope when Buttler (28) and Hales (47) were out in the space of three overs, with the spin of Wanindu Hasaranga accounting for both of them.
Harry Brook (4) quickly followed, caught and bowled by De Silva, then Livingstone (4) carelessly threw his wicket away with a slog, and Moeen Ali (1) joined them back in the pavilion.
But Stokes kept his cool as the wickets tumbled and steered them into the last four alongside Woakes.