Gloucestershre 309 for 9 dec (Gohar 86, O Price 76, Roland-Jones 5-79) need 234 runs to beat Middlesex 377 (Davies 91, Holden 77, De Caires 64, T Price 5-81) and 165 (Robson 50, Bailey 4-30)
Debutant Archie Bailey led the rout as Gloucestershire's bowlers sparked a dramatic Middlesex collapse on an eventful day three at Lord's.
Bailey took 4 for 30 as the hosts crumbled from 122 for 2 to 165 all out, leaving Gloucestershire 234 to win on day four.
Zafar Gohar chipped in with 2 for 22 as the home side lost their way following Sam Robson's 50 at almost a run a ball. Wicketkeeper James Bracey took his tally to 11 catches plus a run out in the match amid the carnage.
Zafar had earlier made a stylish 86 with a six and 10 fours as the visitors rallied from an overnight 154 for 5 to 309 for 9 declared, a deficit of 68.
Skipper Toby Roland-Jones led the wicket quest with 5 for 79, the fifth time in the last nine innings he has taken five wickets or more.
Gloucestershire began the day needing 74 to avoid the follow-on and were dealt and early blow when Roland-Jones castled Tom Price with only two added to the score.
No other home bowler was able to carry the menace of their skipper and after new batter Zafar got underway with an edge through the slips for four, he and Ollie Price set about reducing the deficit.
Price, on his first appearance at Lord's looked untroubled as he moved to 76 before falling into the leg trap to give Henry Brookes his only wicket of the innings.
Zafar played beautifully, mixing sound defence with controlled aggression, sweeping Josh De Caires to raise the 200 before hitting the next ball over mid-off for a one-bounce four. Pace too was summarily despatched, a short one from Brookes pulled to the midwicket fence as he moved to 50 in 108 balls.
Zaman Akhter proved a great foil either side of the lunch interval before Roland-Jones returned to remove him in the first over with the new ball to complete his five-fer, though the decision looked harsh with the impact well above the knee roll.
Zafar cleared the ropes in his quest for a second first-class hundred five years on from his first but came up short when he pinned in front by Higgins, at which point Gloucestershire declared nine down.
Robson quickly avoided a king pair before surviving vociferous appeals for caught behind on 22, Tom Price spreading his arms more than once in a vain attempt to have his cries upheld and all fielders seemingly convinced the ball had been feathered. Robson remained unmoved as the appeals fell on deaf ears
Bailey immediately replaced the crestfallen Price and the youngster soon had a moment to cherish, his maiden first-class wicket, Mark Stoneman caught by Cameron Bancroft diving away to his left at second slip.
A cloudburst prior to tea proved a precursor to a stormy evening for the Middlesex batters.
Robson initially forged on, driving and cutting forcefully until nicking Akhter's first ball through to Bracey immediately after completing his half-century.
Max Holden was even more forceful in his quickfire 39, reverse sweeping Zafar to the boundary twice in quick succession, before falling to a catch in the deep. His dismissal sparked the slide as the hosts either couldn't or wouldn't reverse out of their all-out attacking mindset.
Higgins chopped on before Jack Davies' hesitation over a second run proved fatal, Bracey intercepting the throw from the deep to turn and flatten the stumps.
Bracey would figure in the dismissals of Josh De Caires, Luke Hollman and Roland-Jones as the procession from to and from the pavilion gathered pace while Bailey got the prize wicket of Leus Du Ploy lbw.
Zafar completed the collapse by bowling Brookes for a duck to leave the visitors favourites for a successful run chase tomorrow.