(CNN) -- A century from Shoaib Malik has helped put Pakistan on top in the final Test match against Sri Lanka in Colombo.
Malik's second Test century has put Pakistan in a dominant position against Sri Lanka in Colombo.
Under fire for their poor performances in the first two Tests, Malik and Misbah-ul Haq marked a timely return to form, steering Pakistan away from the possibility of another batting collapse.
Malik struck an unbeaten 106 and put on 119 runs for the fifth wicket with Misbah (65), as Pakistan recovered from three blows in the morning session which left them floundering on 67 for four and in danger of throwing away the advantage of a 66-run first innings lead.
Instead, the visitors reached 300 for five at stumps on the third day, a lead of 366 and with history on their side.
Sri Lanka are the only team to have chased down a target in excess of 200 in the fourth innings at the Sinhalese Sports Club ground -- making 326 against Zimbabwe back in 1998.
But the visitors pressed ahead with Malik adding 114 in an unbroken stand for the sixth wicket with Kamran Akmal (60 not out), the two holding sway at close and in a position to bat Sri Lanka out of contention for a series sweep.
The home side had begun the day in the ascendancy with the wicket of Fawad Alam almost immediately after play had resumed in the morning.
Alam added only a couple of runs to his overnight 14 before he succumbed to a strange half-pull, half-flick shot against a short-pitched delivery from left-arm paceman Thilan Thushara. The 23-year-old Alam was hit high on the bat and presented Thushara with a simple catch and his sixth wicket in the match.
Sri Lanka then chipped away by adding the wickets of Younus Khan and Mohammad Yousuf in relatively quick time.
Pakistan captain Younus made 19 before falling victim to a poor leg-before decision off a Nuwan Kulasekara delivery.
The visitors were 54 for three at that stage and slipped further when left-arm spinner Rangana Herath dismissed Yousuf, forcing him into an edge straight to wicketkeeper Kumar Sangakkara.
Malik and Misbah came together just before the lunch interval and although they had begun their innings slowly, the duo batted solidly.
Misbah extended the lead past the 200-run mark by clubbing Herath for a boundary and a six in one over and reached his third Test half-century by putting away a full-toss from Thushara. He fell in the final session, attempting a cut off Angelo Matthews and edging to Sangakkara.
But Malik and Akmal then stepped up the scoring rate and Malik reached his century -- only his second in Test cricket -- with a massive six off Herath.