Abdullah Shafique and Babar Azam starred as Pakistan chased a record 342-run target against Sri Lanka to take 1-0 lead in the two-match series.
Pakistan were 331 for six with Abdullah Shafique on 154 and Mohammad Nawaz on 12 at the venue in Galle, where the highest successful fourth-innings chase was 268 by Sri Lanka against New Zealand in 2019.
Left-arm spinner Prabath Jayasuriya took four wickets for the hosts and is on the brink of an unprecedented feat of four straight five-wicket hauls in his first two Tests.
He took 12 wickets on debut in a series-levelling Test win over Australia last week at the same venue, six in each innings.
Pakistan resumed the day on 222-3 and Sri Lanka soon used up their remaining two umpire reviews, with Jayasuriya involved in both calls.
Mohammad Rizwan opened his day’s account with a boundary off Ramesh Mendis and kept up his positive intent by taking singles and twos before he fell lbw to Jayasuriya for 40.
A review did not save Rizwan, a wicketkeeper-batsman who has come into the two-match series after a successful stint with English county Sussex.
Shafique, who recorded his second Test century on day four to lead the chase, has stood firm and played the anchor’s role to perfection so far.