Kusal Mendis' 91 and an unbeaten 49 by Charith Asalanka helped Sri Lanka edged out Pakistan by two wickets in a last-ball thriller of the Asia Cup to set up a final clash with India.
Chasing a DLS revised target of 252 in the 42-overs-a-side contest in Colombo, Sri Lanka needed eight from the final over and achieved the target with Asalanka's winning hit on the last ball at 1.07 am local time.
A raucous home crowd rejoiced but the result broke the heart of millions of fans awaiting an India-Pakistan final in the 50-over tournament, a prelude to the upcoming ODI World Cup.
The left-handed Asalanka held his nerve despite Shaheen Shah Afridi's two wickets in two balls in the penultimate over and the first four balls from Zaman Khan giving away just two runs and a wicket in the 42nd over.
Mendis set up victory with a 100-run third-wicket stand with Sadeera Samarawickrama, who made 48, but Asalanka took it on himself after their departure.
Off-spinner Iftikhar Ahmed took three key wickets including Mendis and Samarawickrama to keep the game in the balance till the last.
Earlier Mohammad Rizwan hit an unbeaten 86 to steer Pakistan to 252-7 after they elected to bat first in the rain delayed start to the match.
Sri Lanka's bowlers took regular early wickets to check Pakistan's scoring, but Rizwan hit back with his 12th ODI half-century and a 108-run stand with Iftikhar, who made 47.
Fast bowler Pramod Madushan struck first as he bowled Fakhar Zaman for four with a yorker that raised the decibels in the ground.
Abdullah Shafique (52) and skipper Babar Azam (29) then rebuilt the innings in their stand of 63 despite surviving a few close calls including an lbw review off Dunith Wellalage.
Azam looked to be getting into his groove with a few boundaries but was stumped off Wellalage, a left-arm spinner who was Sri Lanka's star in their previous loss to India with 5-40.
Shafique stood strong and hit two sixes en route to his maiden ODI fifty but soon fell to fast bowler Matheesha Pathirana, who quickly struck again.
Pakistan returned from a rain break on 130-5 with Rizwan digging deep and he got support from Iftikhar, who took his time to get his rhythm and hit two sixes in his 40-ball knock.
Pathirana sent back Iftikhar for his third wicket and Madushan took one more scalp of his own late on, but Rizwan remained unbeaten and finished with a boundary.