Glamorgan cruised to a comfortable 189-run victory over Gloucestershire after bowling the visitors out for 195 in their second innings.
Gloucestershire lost their last six wickets for 31 runs in 10.1 overs at the Swalec Stadium, with Chris Taylor being the last man to fall after a defiant 83.
Resuming on 42 without loss and needing 343 more for victory, the West Country outfit needed only to bat through the day to save the game.
Openers Richard Coughtrie and Ian Cockbain added 20 runs before Adam Shantry trapped Cockbain lbw on 47.
Coughtrie followed after a brilliant direct hit by Gareth Rees and skipper Alex Gidman (7) was caught at mid-wicket off opposite number Alviro Petersen to make it 118-3 at lunch.
Taylor remained at the crease throughout the afternoon as the wickets tumbled around him, spinners Cosker and Petersen claiming two apiece for just 13 runs in a 31-ball spell.
James Harris bowled Jon Batty for 23 with the second new ball and then dismissed Will Gidman for one before Shantry struck in successive balls in the next over to remove Ian Saxelby and Jon Lewis.
Cosker struck again to dismiss Vikram Banerjee and, with Gloucestershire missing Chris Dent who was unable to bat because of a broken finger, the win was complete.
Gloucestershire ended day three at Cardiff on 42 without loss after being set a stiff target of 385 by Glamorgan to win the Division Two clash.
Jim Allenby's patient half-century helped the hosts, who had begun the day on 185-3, reach 370-9 before they declared at tea.
They had lost Ben Wright and Will Bragg in the opening four overs but Mark Wallace teamed up with Allenby to put on a 55-run stand in 21 overs.
Graham Wagg then weighed in with 19 while James Harris contributed a useful 25 in support of Allenby, who finally fell to spinner Vikram Banerjee for 63 having spent over three-and-a-half hours at the crease.
Ian Cockbain reached the close unbeaten alongside fellow opener Richard Coughtrie (seven not out) as the visitors survived 25 overs late in the day.
They will return on Sunday needing a further 343 runs to win a match that they had at one stage seen them reduce their rivals to 54-6 on the opening day.
Glamorgan moved themselves into a strong position as Gareth Rees scored his first 50 of the season against Gloucestershire in Cardiff.
James Harris took 5-39 for the hosts, who ended the second day of the LV County Championship Division Two match on 185-3 in their second innings - a lead of 199 having bowled Gloucestershire out for 188 in 89.1 overs.
Harris broke through in the sixth full over of the morning and Adam Shantry claimed his third wicket when he bowled Ian Saxelby as the visitors, who had resumed the day on 76-5, 126 behind, were reduced to 94-7.
However, Jon Lewis and Vikram Banerjee frustrated Glamorgan either side of lunch, putting on 77 in 39 overs, but the former brought up his half-century in 94 balls with three fours before Harris struck in the fourth over with the second new ball.
Glamorgan openers Rees and Alviro Petersen raced to 44 in 10 overs before tea but, although Rees lost his captain - who was trapped leg before by Saxelby - he went on to register a 71-ball half-century with nine fours.
After putting on 65 in just 11 overs with fellow left-hander Will Bragg, Rees also went leg before wicket to Will Gidman, but Bragg and Ben Wright added 42 runs for the fourth wicket by the close.
Seam bowlers ruled the roost on the opening day between Glamorgan and Gloucestershire in Cardiff as 15 wickets tumbled.
Ian Saxelby's maiden five-wicket haul ensured the home side's decision to bat first backfired as they were shot out for 202 in 47.5 overs.
It could have been even worse for the Welsh county, who found themselves at 26-4 after Jon Lewis (3-40) claimed three lbw victims in his opening spell.
From 56-6, Ben Wright (83) and Graham Wagg (58) scripted a recovery of sorts with a seventh wicket alliance 138 either side of lunch.
But Saxelby, 21, who missed most of last season with a shoulder injury, ran through the tail for figures of 5-53.
Gloucestershire's top order, however, wasted the good work of their bowling attack, slumping to 76-5 by the close, still 126 behind. Glamorgan pacemen James Harris (2-22) and Adam Shantry (2-31) each made two breakthroughs.