Gurbaz's effort came in vain after he put on a key second-wicket stand of 93 with Ibrahim Zadran, who made 40, after Afghanistan were made to bat first.
Afghanistan, who had crushed Sri Lanka and Bangladesh to move into the Super Four stage, managed just 37 runs in the last five overs and lost five wickets.
Dilshan Madushanka, a left-arm quick, took two wickets while fellow fast bowler Asitha Fernando and spinner Maheesh Theekshana claimed one each.
In reply, Sri Lankan openers Nissanka and Mendis started strongly in the powerplay.
Nissanka attacked the bowlers with a few boundaries and then Mendis took over, smashing leg-spinner Rashid Khan for two sixes to bring up his team's fifty.
Fast bowler Naveen-ul-Haq broke through remove Mendis after the batsman's 19-ball blitz.
Nissanka attempted to keep up the charge but fell to spinner Mujeeb Ur Rahman with Gurbaz taking a sharp catch.
Danushka Gunathilaka made 33 to keep the chase on track despite the loss of Charith Asalanka and skipper Dasun Shanaka at the other end.
He found company in the form of Rajapaksa, who smashed Naveen for two fours and one six in an 18-run 16th over to bring down the asking rate.
Rashid bowled Gunathilaka but new man Hasaranga hit three boundaries to take Sri Lanka near their target.
Rajapaksa was out in the 19th over before Chamika Karunaratne hit the winning boundary.