Michael Klinger hit 80 not out to steer Gloucestershire clear of trouble on day two of their Division Two match against Glamorgan at Bristol.
Murray Goodwin scored a century and Mark Wallace and Michael Hogan weighed in with 94 and 51 respectively as Glamorgan posted an imposing 448 in their first innings.
But captain Klinger batted through two sessions and staged crucial partnerships with Gareth Roderick and Dan Housego to help the home side reach 179-1 at the close, still 269 runs behind.
The Australian rode his luck at times and was twice dropped, the second coming on 36 when Stewart Walters fumbled should have been a regulation catch.
Resuming on 318-5, Glamorgan added 130 more runs in an eventful morning session with Goodwin registering his 68th first-class hundred.
Goddwin's patient innings of 108 that spanned 221 balls was finally terminated when he became the first of three batsmen to fall to Craig Miles in the space of seven balls as Glamorgan slipped from to 343-8.
But Glamorgan skipper Wallace and Hogan slammed the door shut on Gloucestershire in a whirlwind alliance of 68 in 11.1 overs, the former the last man out and finishing six runs short of a hundred.
Wicketkeeper Roderick fully justified the decision to promote him to open the batting, contributing 41 runs in a stand of 79 with Klinger.
Roderick looked to be on course for a half-century but Michael Hogan pinned him lbw to make a breakthrough shortly before tea.
But Klinger and Housego proved immovable thereafter, the former safely negotiating 191 deliveries and the latter offering staunch support to reach the close unbeaten on 46 from 118 balls.