Half-centuries by Younis (64 not out) and Azhar (58 not out) steadied the innings after Josh Hazelwood took two wickets in an over.
Sydney: An unbeaten century stand by Azhar Ali and Younis Khan on Wednesday rallied Pakistan from a dire start to be 126-2 at stumps on day two at the Sydney Cricket Ground, still trailing Australia by 412 runs but with renewed hope of avoiding the follow-on.
Half-centuries by Younis (64 not out) and Azhar (58 not out) steadied the innings after Josh Hazelwood took two wickets in an over soon after Australia captain Steve Smith had declared at 538-8 just before tea.
Peter Handscomb joined openers David Warner (113) and Matt Renshaw (184) as centurions for the hosts, scoring 110 for his second test ton in four matches, and some big hitting late in the innings by Matt Wade and Mitchell Starc lifted the score over 500.
A rout similar to last week's capitulation by Pakistan on the final day of the second test at Melbourne looked increasingly likely when Hazelwood made his double strike.
Hazelwood first removed Sharjeel Khan caught at slip by Renshaw for four and then trapped Babar Azam lbw for a duck four balls later to leave the visitors at 6-2 and with a steep climb required to avoid a series clean sweep.
Younis' half-century came off 98 balls with seven boundaries as the 114-match veteran batsman found the type of form that has him nearing 10,000 test runs.
Azhar brought up his second fifty of the tour, to go with his 205 not out in the second test at Melbourne, with an edge through gully in the final moments before stumps. He was lucky to survive the next over when he edged a sharp chance to Warner, who could not grasp the chance at leg slip.
Earlier, Handscomb raised his century after lunch with a single off spinner Yasir Shah. Handscomb's ton came off 195 balls with nine boundaries.
He was dismissed soon after in bizarre circumstances when his bat grazed the leg stump and dislodged the bail while attempting to cut a Wahab Riaz (3-89) delivery, to be out hit wicket.
Debutant Hilton Cartwright made 37 before being bowled by Imran Khan (2-111) for the seamer's second wicket of the day and Matt Wade scored an enterprising 29 before lofting a simple catch to Babar off Azhar (2-70).
Smith then declared the host's innings when Mitchell Starc (16) holed out to the deep off Azhar as Australia chased quick runs.
In the morning session, Renshaw's bid to become the youngest Australian to score a test double-century fell 16 runs short.
The 20-year-old was attempting to become the youngest Australian to reach 200, a mark Don Bradman reached three times when aged 21 years. But his patient innings, in stark contrast to his opening partner Warner's blistering century in the first session yesterday, ended on 184 when he played on to his own stumps from a rising Imran delivery.
His near seven-hour innings came off 293 balls, with 20 boundaries, and will put him as a strong contender to retain his place in the team for the four-test tour of India, starting February.
After winning the toss and batting, Australia dominated the Pakistan bowling attack on the first day Tuesday, with Warner becoming the first player to score a hundred in the opening session of a test in Australia, and just the fifth player anywhere to achieve the feat.