The Pakistan captain's feat came after double centuries by Ijaz Ahmed and Inzamam-ul Haq had left Sri Lanka on the brink of defeat. Ijaz made 211 and Inzamam an unbeaten 200 as Pakistan piled up 594.
Wasim then created a sensation as Sri Lanka, needing 364 to avoid an innings defeat, slipped to 9 for 3 in 13 balls.
The left-arm fast bowler, who achieved the feat in last week's Lahore Test against Sri Lanka, had Avishka Gunawardena caught at slip off his fifth ball and shattered Chaminda Vaas' stumps off the next. After an over from Shoaib Akhtar at the other end, Wasim had Mahela Jayawardena caught with his first ball of the next over. The umpires then called off play for the day.
"It was quite unbelievable," said Wasim, who took his tally to 378 Test wickets and joined the queue with West Indian Courtney Walsh (404) to break Indian Kapil Dev's record of 434.
"I think Walsh will get there and I hope I can. Two hat-tricks in as many matches is something I never dreamt of, but it gives me the confidence to reach the summit. My immediate task however is to win the Asian final.
The hat-trick overshadowed masterly batting by Ijaz and Inzamam, who hit career-best scores on the slow pitch at the Bangabandhu National stadium.
Third day; Sri Lanka won the toss
SRI LANKA - First Innings 231 (P A De Silva 72; Arshad Khan 5-38).
PAKISTAN - First Innings
Ijaz Ahmed st Tillekeratne b Chandana 211
Inzamam-ul-Haq not out 200
Yousuf Yohana c sub b Chandana 19
Shahid Afridi c and b Chandana 21
*Wasim Akram c Vaas b Chandana 8
Moin Khan c Sajeewa b Arnold 10
Saqlain Mushtaq run out 4
Arshad Khan c Tillekeratne b Chandana 3
Shoaib Akhtar st Tillek'tne b Chandana 4
Extras (lb14 nb8 b13) 35
Total (all out, 184.4 overs) 594
Fall (cont): 3-483, 4-515, 5-518, 6-534, 7-542, 8-555, 9-560.
Bowling: Vaas 32-4-101-0 (nb-3); Wickremasinghe 20-4-53-0 (nb-1); Sajeewa 25.4-3-75-1 (nb4); Chandana 47.4-8-179-6; Aravinda 12-0-44-0; Arnold 37.2- 6-80-2; Mahela 10-1-35-0.
SRI LANKA - Second Innings
R P Arnold not out 8
A Gunawardena c Afridi b Wasim 0
W P U J C Vaas b Wasim 0
D P M Jayawardene c Wasti b Wasim 1
Total (for 3, 2.1 overs) 9
Fall: 1-5, 2-5, 3-9.
Bowling (to date): Wasim Akram 1.1-0-5-3; Shoaib Akhtar 1-0-4-0.
To bat: *P A De Silva, M S Atapattu, H P Tillekeratne, R S Kaluwitharana, G P Wickremasinghe, U D U Chandana, S K L De Silva.
Umpires: D Cowie(NZ) and D Shepherd (Eng).Reuse content