Pakistan beat Australia by 221 runs to take a 1-0 lead in two-match Test series being played in Dubai.
After setting an imposing 438-run target, Pakistan rattled the Australians through a brace of wickets apiece from spinners Zulfiqar Babar and Yasir Shah to leave Australia tottering on 59-4 at stumps on the fourth day on Saturday, needing six wickets for a 1-0 lead in the two-Test series.
Chris Rogers (23) and Steven Smith (three) were at the crease as Australia need another 379 for an unlikely win.
Australia's best chase to win a Test was way back in 1948 when they made 404-3 against England at Headingley while their best chase against Pakistan was 369-6 at Hobart in 1999.
Australia had raced to 44-0 before Babar struck twice in the 14th over, inducing David Warner, who had scored his third successive test century in the first innings, to come out of the crease for a smart stumping when he was on 29 with his first ball and then trapped Alex Doolan (nought) leg before with his last.
Michael Clarke survived a review leg-before decision on nought off Shah before trapped in front of the wicket in the leg-spinner's next over for three.
Clarke was disappointed at his failure.
“I'm really disappointed with my personal performance in this Test match, “said Clarke who made two in the first innings.
“I am not looking to blame anybody else or criticise anybody else. But if you look at all facets of the game we've been outplayed at this stage.
“We've got to fight our backsides off tomorrow and see what happens.“
Shah made it 4-49 catching nightwatchman Nathan Lyon in front of the wicket on a day dominated by Pakistan.
Younis hit a record making 103 not out and Shehzad 131 to bolster Pakistan to 286-2 declared.
Younis added 168 for the second wicket with Shehzad as Pakistan plundered 248 runs after resuming at 38-0.
Younis swept Steve O'Keefe to square-leg boundary for his sixth boundary to get to his second hundred in the match following his 106 in Pakistan's 454 in the first innings.
Australia conceded a big 151-run lead after being dismissed for 303 in their first knock.
Younis became the seventh Pakistani batsmen, but first against Australia, to score twin hundreds in a Test.
Hanif Mohammad (1964), Javed Miandad (1984), Wajahatullah Wasti (1999), Yasir Hameed (2003), Inzamam-ul Haq (2005) and Mohammad Yousuf (2006) had also achieved the distinction in the past.
With his 26th hundred, Younis also edged ahead of Inzamam (25 hundreds) as the highest Test century maker for his country.
It was actually Shehzad who set the tone for quick runs in the morning.
Shehzad, 22, drove paceman Peter Siddle for his eighth four towards long-on to reach his second Test hundred.
Pakistan, 116-1 at lunch, cut loose in the second session against a hapless Australian attack on a flat pitch.
Shehzad smashed a four and a six off O'Keefe and then hit Mitchell Marsh twice to the ropes to enter the 90s.
After reaching his hundred, Shehzad smashed two fours and a six off Siddle to take the lead past 370.
He was trapped leg-before soon after tea by spinner O'Keefe, the only successful Australian bowler with 2-112.
In the morning, Australia had looked to stop the flow of runs and had a good chance of breaking through early, but Brad Haddin failed to grasp a low catch when Shehzad edged one on to the pads which popped out of the wicketkeeper's hands.
But O'Keefe got his reward when he induced an edge off Ali straight into the hands of Haddin with the score at 71.
Younis hit a six off Lyon and then drove Mitchell Johnson to cover boundary to complete his 29th half-century in Tests, before cutting loose to his hundred.
The second and final Test starts in Abu Dhabi on October 30.