They were finally out for 302 on day three of the pink-ball Test, 287 runs adrift, with a dogged Yasir the last man to go for 113.
Australia immediately enforced the follow on, leaving Pakistan to face a difficult evening session.
Better known as a spin bowler than a batsmen, Yasir had never gone better than 42 in his previous 36 Tests, making his maiden century against one of the world’s most fearsome pace attack’s even more remarkable.
In a scintillating spell under lights on Sunday night, left-armer Starc snapped up four quick wickets and the omens for Pakistan did not look good.
But the gloomy conditions at Adelaide Oval offered little movement to the bowlers on Sunday and Azam and Yasir took advantage.
They put on a disciplined 105-run stand with Azam looking destined for a third Test century until Starc pounced again, with the 25-year-old edging an attempted drive to Tim Paine behind the stumps on 97.
Azam — who scored a century in the first Test at Brisbane and is rapidly emerging as his country’s top batsmen — left the field dejected but to a standing ovation.
The very next ball Starc grabbed his sixth, with Shaheen Afridi plumb lbw before Abbas fended off the hat-trick ball.
He finished with 6-66 — his 12th five-wicket Test haul.
Mohammad Abbas joined Yasir at the crease and made a gutsy 29 before he was undone by a Pat Cummins bouncer, caught at gully by Warner.
At the other end, Yasir showed composure to compile his first-ever ton, bringing up the milestone off 192 balls, clattering 12 fours and kissing the turf in celebration.
He had a near-miss off the bowling of Marnus Labuschagne on 33. Steve Smith believed he caught him at slip and made a big appeal, but replays showed the ball fell just short of his fingertips.
Yasir was then dropped by Labuschagne off his own bowling on 43. He was finally out hooking a Cummins delivery to Nathan Lyon.