Charith Asalanka held his nerve as Sri Lanka edged a last-ball thriller against Pakistan to set up a meeting with India in the Asia Cup final.
Chasing a revised Duckworth-Lewis-Stern target of 252 in their final Super Four match, Kusal Mendis made a crucial 91.
With six needed off the final two balls Asalanka edged Zaman Khan for four then calmly worked a couple off his pads.
Pakistan had earlier posted 252-7 thanks to Mohammad Rizwan's unbeaten 86 after the start was delayed by rain.
The win gave Sri Lanka the runners-up spot in the Super Four stage and they will face table-topping India, who play winless Bangladesh on Friday, in Sunday's final.
"We are very happy to come to the final," said Mendis. "Overall everyone played really well.
"A couple of wickets went down, but I was hoping that Charith would finish the game as he has done it before. And he did it."
Abdullah Shafique (52 off 69 balls) and captain Babar Azam (29 offf 35) laid the foundation for Pakistan's total before Rizwan's impressive knock, off 73 balls, was supported by Iftikhar Ahmed (47 off 40), while Matheesha Pathirana finished with 3-65.
Wicketkeeper Mendis spearheaded Sri Lanka's reply in a century stand for the third wicket with Sadeera Samarawickrama, who made 48 off 51, but fell nine runs short of a third ODI century when he was dismissed by Iftikhar, who took 3-50.
Shaheen Afridi's two wickets in two balls in the penultimate over appeared to swing the momentum Pakistan's way, leaving Sri Lanka needing eight from the final over.
Pramod Madushan was run out off the fourth ball, but Asalanka kept his cool, finishing unbeaten on 49 to get Sri Lanka over the line in front of a raucous home support at the R. Premadasa Stadium as the clock ticked past 01:07 local time.
"Sri Lanka played very well, better cricket than us," said Pakistan skipper Babar.
"We have not been up to the mark in the bowling and fielding. That is why we lost the match."