Pakistan's Azhar Ali smashed a second century in successive matches on Wednesday to leave the final Test against Sri Lanka poised for an intriguing finish.
Azhar made 136 as Pakistan wriggled out of a corner to post 299-8 in their second innings by stumps on the fourth day in Pallekele, a lead of 188 runs with two wickets in hand.
The tourists now have three sessions on the fifth day to conjure a series-levelling win on a wearing pitch that will offer some turn to prolific off-spinner Saeed Ajmal.
But Sri Lanka remain favourites to win or draw the match and clinch their first series victory in three years since beating New Zealand at home in 2009.
The hosts won the first Test in Galle by 209 runs before the second in Colombo was drawn.
Sri Lanka's South African coach Graham Ford conceded it was hard to predict how the Test will end.
"The way it has swayed back and forth over the four days, I don't think anyone can say what will happen tomorrow," said Ford.
"The game is still pretty much even. Pakistan has a very good attack but we too will be confident of doing well on the last day. This is what makes Test cricket so exciting."
Azhar, who made 157 in the Colombo Test, held the innings together for six hours, hitting 13 boundaries in his fourth Test century and the third this year.
The 27-year-old put on 94 for the second wicket with his overnight partner Mohammad Hafeez and 48 for the third with Younis Khan after Pakistan resumed the day at 27-1.
But the most crucial partnership came towards the end of the day when Asad Shafiq (55 not out) helped Azhar add 100 for the fifth wicket after Younis and skipper Misbah-ul Haq had departed quickly.
Fast bowler Dilhara Fernando and left-arm spinner Rangana Herath sparked a lower order collapse in the final hour as Pakistan slipped from a comfortable 276-4 to 299-8.
Fernando had Azhar caught behind and then claimed his 100th Test wicket by trapping Mohammad Sami leg-before.
Herath claimed Umar Gul and Saeed Ajmal leg-before, but Shafiq saw out the day for Pakistan in the company of Adnan Akmal, who batted despite a hairline fracture in his left hand.
"It was disappointing to get out because Asad and myself had decided to see out the day," said Azhar. "But I am happy to get another century. I have batted well this year and want to make good use of my form."
Azhar did not rule out a Pakistan win on Thursday. "We have the bowlers to do the job for us," he said. "I think the total we have is good enough to defend.
"The wicket has slowed down, but there is still something in it for the bowlers."
Hafeez, who also hit a century in Colombo, made 52 when he was dismissed just before lunch with Pakistan two runs away from wiping out the first innings deficit of 111 runs.
The Pakistan vice-captain edged a wild drive off Fernando to Tharanga Paranavitana in the slips.
Pakistan went to lunch at 119-2, in front by eight runs, after Younis had given his team the lead by tapping Angelo Mathews for a single to point.
Herath dismissed both Younis and Misbah and ended the day with 4-64. Fernando finished with 3-65.