Ajmal got the prized wicket of Kumar Sangakkara [ Images ], who completed his 27th Test century on Thursday, but that could not stop Sri Lanka from amassing 413 all out on day two of the match.
Pakistan were delivered a further setback as they lost both their openers cheaply to close at 35 for two.
Sangakkara and Mahela Jayawardene [ Images ] had been expected to build up on their overnight third wicket partnership of 68 but added only another 16 runs before Jayawardene (39) was controversially given out lbw to Junaid Khan by umpire Simon Taufel.
Sangakkara went on to score an elegant 144, stroking 13 fours and belting two sixes, and was left extremely frustrated when he misjudged a pull shot that fell straight into the hands of Younus Khan.
Ajmal also claimed the scalps of wicketkeeper Kaushal Silva and Kosala Kulasekara [ Images ] on Friday to finish with four for 132.
Pakistan's hopes of mounting a fightback got off on the wrong foot as Mohammad Hafeez [ Images ] departed for just six. His thick edge appeared to be flying towards the boundary but a diving Jayawardene at third slip grabbed the ball with both hands.
Fellow-opener Taufeeq Umar [ Images ] was stumped by Silva for 19 to leave Pakistan struggling on 35-2 when stumps was called.
Pakistan claimed an easy nine-wicket win in the second Test in Dubai [ Images ].
The 'home' matches for Pakistan are being played in the Gulf region due to security concerns.
Sri Lanka (1st innings): (245-2)
T Paranavitana c Younis b Gul 4
T Dilshan [ Images ] c Younis b Ajmal 92
K Sangakkara c Younis b Ajmal 144
M Jayawardene [ Images ] lbw b Khan 39
A Mathews c Akmal b Rehman 17
K Silva c Ali b Ajmal 39
K Kulasekara lbw b Ajmal 15
S Randiv lbw b Gul 1
D Prasad c Akmal b Khan 17
R Herath not out 34
C Welegedara b Gul 0
Extras: (LB-5, NB-6) 11
Total: (all out in 153.3 overs) 413
Fall of wickets: 1-4, 2-177, 3-261, 4-300, 5-304, 6-330, 7-331, 8-359, 9-413, 10-413.
Bowling: Gul 29.3-10-76-3, Khan 27-4-94-2, Ajmal 51-4-132-4, Rehman 45-14-103-1, Hafeez 1-0-3-0.
Pakistan (1st innings):
Mohammad Hafeez c Jayawardene b Welegedara 6
Taufiq Umar st Silva b Herath 19
Azhar Ali not out 10
Younis Khan [ Images ] not out 0
Total: (for 2 wkts in 20 overs) 35
Fall of wickets: 1-8, 2-35
Bowling: Welegedara 5-1-11-1, Prasad 4-0-9-0, Kulasekara 3-0-14-0, Herath 5-4-1-1, Randiv 3-3-0-0.