Shoaib finished on 57, Pakistan's highest Twenty20 score, surpassing the 53 struck by Misbah ul-Haq in the team's previous match against India, while Afridi took 3-18 to put the skids on Sri Lankan batting.
Earlier Malik and Younis Khan shared Pakistan's first international Twenty20 century partnership to lift their side to a competitive 189 for six. In reply, the Lankans could manage only 156 for nine.
Sri Lanka, who won the toss and bowled first, picked up three early wickets but Shoaib and Younis then ripped into the bowling in their Group F clash.
They struck 101 runs off the 58 balls they shared and were particularly severe on left-arm spinner Sanath Jayasuriya, taking 46 runs off his first three overs.
Shoaib reached his half-century in just 27 balls, beating the 33 deliveries needed by Misbah. Younis slammed his 51 off 35 balls, with three sixes.
Jayasuriya bowled the final over and Misbah hit him for two sixes over long-off.
Jayasuriya conceded a total of 64 runs, equalling the most expensive Twenty20 bowling tally recorded by England paceman James Anderson against Australia in Sydney earlier this year.
Fast bowler Dilhara Fernando restricted Pakistan at the start of their innings and finished with two for 17, while Lasith Malinga stemmed the tide of runs with three wickets.
Later, Afridi halted the Lankan chase by picking up the wickets of Mahela Jayawardene (28) and Chamara Silva (38), while Mohammed Asif chipped in with two important wickets.
PAKISTAN
Butt b Fernando........................12
Nazir c Mubarak b Vaas..............7
Hafeez b Fernando....................10
Younis c Dilshan b Malinga......51
Malik c Dilshan b Malinga........57
Afridi b Malinga........................17
Akmal (not out)........................10
Misbah (not out)......................16
Extras (LB-3, W-4, NB-2)...........9
Total (6 wkts; 20 overs)..........189
Fall of wickets:1-22, 2-22, 3-33, 4-134, 5-152 , 6-170.
Bowling: Chaminda Vaas 4-0-23-1, Dilhara Fernando 4-1-17-2, Lasith Malinga 4-0-43-3, Sanath Jayasuriya 4-0-64-0, Gayan Wijekoon 4-0-39-0.
SRI LANKA
Tharanga c Gul b Asif..................0
Jayasuriya b Tanvir......................5
Sangakkara b Asif......................18
Jayawardene c Hafeez b Afridi..28
Silva b Afridi.............................38
Dilshan c Younis b Hafeez........38
Mubarak c Afridi b Gul...............0
Wijekoon c Hafeez b Afridi.........0
Vaas (not out)...........................12
Malinga c Younis b Gul...............1
Fernando (not out)......................0
Extras (LB-5, W-9, NB-2)..........16
Total (9 wkts; 20 overs)...........156
Fall of wickets:1-0, 2-5, 3-35, 4-88, 5-111, 6-112 , 7-115 , 8-150 , 9-155 .
Bowling: Mohammed Asif 4-0-47-2, Tanvir Sohail 4-0-26-1, Mohammed Hafeez 4-0-46-1, Shahid Afridi 4-0-18-3, Umar Gul 4-0-14-2.