Brisbane - Asad Shafiq scored a thrilling century as Pakistan put up a spirited resistance to Australia on Sunday, frustrating the hosts' attempts to wrap up the first Test with a day to spare.
Shafiq dashed for three runs off a cut shot in the final over of the fourth day to reach his 10th Test century off 140 balls in the day-night match at the Gabba.
The tourists, who have lost their last nine Tests in Australia, refused to buckle despite the loss of key batsmen Younis Khan, Azhar Ali and skipper Misbah-ul-Haq.
At the close on a storm-hit day, with Shafiq leading the way, Pakistan had just two wickets left and were 382 for eight - the highest fourth innings in a Test at the Gabba.
They trail the home side by 107 heading into Monday's final day.
"Asad Shafiq was struggling and he came back with a bang," Azhar said.
"We really enjoyed his innings and the way he batted, it was a really special knock, and also special how Mohammad Amir and Wahab Riaz batted as well.
"It will help to grow more confidence, going through the series."
Steve Smith gave Shafiq a life on 72, dropping a clear two-handed chance at second slip off Mitchell Starc's bowling when three regulation overs were left in the day.
Play was extended by an extra half-hour to try to secure a result but the tourists held firm.
Shafiq took the game to Australia and led the resistance with a belligerent knock including 10 fours and a six, spiced with some lively running between wickets.
Mohammad Amir, in the first year of his return to international cricket following a five-year ban for spot-fixing, hit his highest Test score in a stubborn 92-run seventh-wicket partnership with Shafiq.
Amir's previous best was 39 not out against England at The Oval in August, but he fell late in the session for 48 off 63 balls with five fours.
The Australian bowlers endured a long grind, with a three-hour final session ending only at 10:09 pm, after a fierce storm lashed the ground just before tea.
The bowlers, who decimated Pakistan by taking seven wickets for 24 in the first innings, were frustrated by a lack of assistance from the pink ball under lights in the second.
"It probably didn't go to plan. No doubt we wanted to finish off the game today. Hats off to Pakistan, they batted particularly well," said Australia bowling coach David Saker.
"We're still in a very good strong position. I'd prefer to be in our position than theirs. We've got to come back and get two quick wickets tomorrow."
Australia are defending an unbeaten run of 27 Tests at the Gabba. Their last defeat here was in 1988 to the West Indies.
The hosts went into the final night session needing five wickets for victory and removed the first-innings top-scorer Sarfraz Ahmed for 24.
Starc scattered his stumps with an inswinger in the 88th over, his third wicket, and Jackson Bird had Amir caught behind in the 107th over.
But number nine Wahab Riaz hit a blazing 30 off 56 balls with two fours and two sixes.
Younis Khan had earlier also kept the bowlers at bay but was out to a rash shot 30 minutes before the dinner break.
The 112-Test campaigner fell to an ill-judged reverse sweep off spinner Nathan Lyon, the ball ballooning off the back of his bat for Smith to take an easy catch.
Starc persisted with a short-pitched plan after a 90-minute storm delay at tea.
It finally paid off when Azhar Ali tried to flick a rising ball down to fine leg, only to edge to Matthew Wade.
Azhar faced 179 balls for his 71 and put on 91 for the third wicket with Younis.
Younis, out for a first-ball duck in the first innings, took 20 balls to get off the mark with a streaky shot through the slips cordon to the boundary.