Dilshan's caught-and-bowled of McKay ended Sri Lanka's long wait for the final wicket.
Sri Lanka barged into the Champions Trophy semi-finals with a 20-run victory over holders Australia in the last league match at the Oval in London on Monday.
The Islanders, who needed a win to remain in the competition, rode on aggressive half-centuries from Mahela Jayawardene and Lahiru Thirimanne to score 253-8 after being sent in to bat.
Seamer Nuwan Kulasekara then picked up three wickets, effected a run-out and took a catch as the Australians were bowled out for 233 in 42.3 overs.
Sri Lanka and England finished level with four points each, but the hosts topped the group due to a superior net run-rate and will meet group B runners-up South Africa in Wednesday's semi-final at the Oval.
Sri Lanka will clash with group B winners India in the second semi-final in Cardiff on Thursday in a a repeat of the 2011 World Cup final in Mumbai which the Indians won.
The final is scheduled to be played at Edgbaston, Birmingham on Sunday.
Jayawardene, who became the eighth batsman to complete 11,000 one-day runs when he reached 62, anchored the middle-order with an unbeaten 84 off 81 balls.
Australia, who needed to win in 29.1 overs to qualify, made a brave bid to force their first victory in the tournament with belligerent batting led by Adam Voges' top score of 49.
The Aussies were 192-9 when the last-wicket pair of Clint McKay and Xavier Doherty gave Sri Lanka a fright by adding 41 amid mounting tension.
Tillakaratne Dilshan ended the drama with a spectacular return catch to dismiss McKay, who made a career-best 30. Doherty remained unbeaten on 15.
The fightback would have been followed keenly by New Zealand, who would have joined England in the semi-finals if the last pair had scored the remaining runs.
In the end, the Black Caps were stranded on three points, one behind both England and Sri Lanka. Australia finished with just one point through a rain-affected game.
Glenn Maxwell smashed 32 off 20 balls as Australia raced to 59-2 in 6.3 overs before he was bowled off sling-arm fast bowler Lasith's Malinga third delivery.
Maxwell, a million-dollar signee with Indian Premier League franchise Mumbai Indians, hit five fours and a six before falling to his IPL team-mate.
Kulasekara, who bowled Shane Watson and had Phil Hughes caught behind, ran out Australian skipper George Bailey with a direct throw from fine leg to make it 69-4 in the ninth over.
Matthew Wade picked up the scoring rate with a 22-ball 31 that contained four boundaries and a six, adding 47 for the sixth wicket with Voges.
Voges was ninth out, caught in the deep off Rangana Herath, before McKay and Doherty delayed the end.
Sri Lanka lost left-hander Kusal Perera off the third ball of the match, leg-before to left-arm fast bowler Mitchell Johnson, who finished with three wickets for 48 runs.
Dilshan (34) helped Thirimanne (57) resurrect the innings with a 72-run stand for the third wicket.
Did you have Mahela Jayawardene in your Fantasy Cricket team?