Northamptonshire 343 (Newton 70, Levi 56, Duckett 52) and 50 for 5 lead Gloucestershire 265 (Hankins 73, Gleeson 5-46) by 128 runs
An impressive performance by a patched-up attack to secure a first-innings lead of 78 for Northamptonshire was severely undermined when they lost their first five second-innings wickets for 19.
In a terrific display of new-ball bowling - in complete contrast to the first innings - Gloucestershire's Liam Norwell and left-armer David Payne left Northamptonshire's outside chance of promotion to Division One looking decidedly fragile in a match they probably need to win.
They were backed up by some fine catching, too, as George Hankins dived to his right at third slip to snap up an edge as Payne removed Rob Newton for a single, before Will Tavare moved sharply to snare Ben Duckett at second slip and give Norwell his first success.
Payne then came up with a beautiful delivery to uproot left-hander Max Holden's off stump, before Norwell pinned Rob Keogh in his crease and produced another cracker four balls later to clip the top of off as Richard Levi groped helplessly.
It had taken only six overs to wreck what had been shaping up as an excellent day for the perennial over-achievers, who are nicely placed to advance to the knockout stage again in the NatWest Blast, in which they are looking to become Twenty20 champions for the third time in five seasons, and had put themselves in contention to return to the top division by winning three of their last four red-ball matches.
They recovered a little to 50 for 5 at the close but will need a big innings from captain Alex Wakely if they are to construct a lead substantial enough to have a chance of defending.
A maiden five-wicket haul for Richard Gleeson had been the key factor in dismissing Gloucestershire for 265, despite the absence of their leading wicket-takers, Ben Sanderson and Nathan Buck, as well as spinner Graeme White, whose injuries have left them seriously short of bowling resources.
In addition to Gleeson, the late starter whose success so far has been mainly in T20 and who had played only one first-class match in 2017 before this one, their attack included left-arm spinner Simon Kerrigan, who has arrived on a month's loan after falling down the pecking order with Lancashire, and Atif Sheikh - remember him? - who had played only one first-class match in more than two years.
Each of them claimed a wicket, although neither seized his chance anywhere near as impressively as Gleeson. The 29-year-old right-arm seamer from Blackpool had not played any county cricket until two years ago and did not have a contract until this year.
A huge success already in T20, in which he took 14 wickets last season despite missing Finals Day through injury and has another 10 this summer, Gleeson demonstrated transferable skills by removing both Gloucestershire openers with the new ball, backing that up with a fine spell in the afternoon that saw Jack Taylor and Craig Miles dismissed off consecutive deliveries and, after Kieran Noema-Barnett had defied his hat-trick attempt, completing the quintet with the wicket of academy offspinner George Drissell, who was making his debut.
Late movement accounted for Gareth Roderick and Tavare, who edged to wicketkeeper and second slip respectively, while it was a brute of a ball that did for Taylor, who could only fend to the one slip. The yorker that he has used so effectively in T20 then did its job against Miles and Drissell.
Gleeson was understandably chuffed with 5 for 46 against his name, although it would have been better still had Adam Rossington been able to bring the ball safely under his control as Hankins, who went on to make 73, edged one on 33 just before lunch.
Kerrigan, who has never been the same since that horrible Test debut in 2013, has made only two Championship appearances this season for Lancashire, where Stephen Parry, Matt Parkinson and perhaps even Arron Lilley are seen to have moved above him in the spin-bowling hierarchy.
He showed the skills were still intact when he lured Phil Mustard down the track and spun the ball on to the stumps past the inside edge, although Keogh's offspin did more damage overall, removing Hankins and Ian Cockbain in the space of seven balls after a fourth-wicket stand of 69. Keogh later dismissed Noema-Barnett, lbw slog-sweeping for a feisty 59.
Sheikh, who played for Derbyshire in 2010 and for Leicestershire from 2014 to 2016, does have a hat-trick against Gloucestershire to his name, in 2014, albeit one of limited impact given the opposition total was 591 at the time. He has been playing 2nd XI cricket for Northamptonshire in the hope of rebuilding his career.
He took a while to find his rhythm but was eventually rewarded when he took out Payne's middle stump.
The weather forecast for the final two days is not encouraging, although the action thus far has unfolded swiftly enough to suggest a positive result is still likely.