Marsh held one end intact with an unbeaten 75 and with him number 10 Peter Siddle was 23 not out as Australia reached 239-8 at tea on the third day at Sheikh Zayed Stadium.
Australia still need another 132 runs to avoid the follow-on with just two wickets intact.
Pakistan, who lead the two-match series 1-0, had posted a big 570-6 declared in their first innings.
Australia lost four wickets in the morning session and then another three in the post-lunch session as Pakistan looked in a strong position to clinch their first series win over Australia since 1994.
More From This Section
Australia had hoped skipper Michael Clarke, who managed just two and three in the first Test, would bat long enough to counter the Pakistan attack but he fell after scoring an attractive 47.
Clarke looked set during his 62-ball spell at the crease, hitting seven boundaries before he was bowled through the gap with a sharp incoming delivery by paceman Imran Khan who had figures of 2-54.
Clarke added 64 for the sixth wicket with Marsh.
Marsh continued to bat solidly and hit a six off Babar and then took three runs to complete his half-century off just 56 balls. He has so far hit 11 fours and a six.
Zulfiqar Babar, Shah and Rahat Ali also have two wickets apiece.
Resuming at 22-1, Australia lost David Warner in the sixth over of the day when the left-hander played straight into the hands of point on a short delivery from Rahat.
Glenn Maxwell, who made 37, tried to take the attack to the bowlers with two boundaries and hit a six off Babar but the veteran spinner had the last laugh when he spun one across the bat to hit the off stump.