Tim Murtagh grabbed his fourth five-wicket haul in the County Championship this season as Middlesex rolled Gloucestershire over for 137 to clinch victory inside three days at Merchant Taylors' School.
Chasing 216, Gloucestershire were blown away by a three-wicket burst from the veteran seamer (5-44), who later returned to break a stubborn eighth-wicket partnership and secure only his side's second Championship win of the campaign.
In between Murtagh's spells, Tom Helm and Toby Roland-Jones, who had earlier dragged their side out of the mire with their partnership of 99, ripped through the middle order as Gloucestershire crashed to 40-7.
Graeme van Buuren defied the home side with a feisty unbeaten half-century, his first of the season, but Roland-Jones finished Gloucestershire off, recording match figures of 10-79 to seal victory by 78 runs.
Resuming their second innings at 96-3, Middlesex's prospects of victory appeared to take an immediate blow when Dawid Malan departed to the first ball of the day for eight, a rising delivery from Josh Shaw that brushed his glove and flew through to Gareth Roderick.
The ball continued to fizz off the surface, making it hard work for the batsmen, with George Scott taking a nasty blow on the hand when another Shaw delivery spat.
Scott (22) eventually fell to Chad Sayers, with Benny Howell snapping up the slip catch after James Bracey had palmed it up, and Ryan Higgins (4-35) completed his best figures of the season when Robbie White was caught behind for 10.
When David Payne trapped John Simpson (10) lbw, Middlesex were deep in trouble at 124-7, with an overall lead of just 95.
But Roland-Jones (51 not out) and Helm (46) turned the tide as they set a Middlesex record for the eighth wicket against Gloucestershire.
Both batsmen adopted an attacking approach, frustrating Gloucestershire to the extent that they finally turned to the spin of Van Buuren after 145 overs of uninterrupted pace bowling.
However, it was Payne who took the new ball and struck almost immediately by having Helm caught in the slips, just after Roland-Jones had reached his first Championship half-century since September 2017.
He remained unbeaten as Sayers (3-60) cleaned up the Middlesex innings for 244 with the wickets of Nathan Sowter (5) and Murtagh (9), leaving the visitors to chase 216 for victory.
They made the worst possible start, though, as Murtagh removed skipper Chris Dent, caught at third slip, with the first ball of the innings.
The Ireland international struck again twice before tea, overtaking Wayne Daniel in the all-time list of Middlesex's most prolific bowlers as he dismissed Bracey (15), who was leg before without playing a shot.
Miles Hammond (16), who had survived an earlier lbw appeal, was next to go as he edged to Stevie Eskinazi in the slips, and Gloucestershire's dramatic slide continued to gather pace after the interval.
Wicketkeeper Simpson sprang to his right to remove Roderick (4) off Helm, who claimed his second victim when Ben Charlesworth (2) edged to third slip, while Howell (1) and Higgins (2) both fell to Roland-Jones.
Payne (16) helped Van Buuren (57no) to add 51 for the eighth wicket, but Murtagh returned to uproot his leg stump and then had Shaw (0) caught behind before Roland-Jones rounded off his side's success.
ga('create', 'UA-72310761-1', 'auto', {'name': 'pacontentapi'});
ga('pacontentapi.set', 'referrer', location.origin);
ga('pacontentapi.set', 'dimension1', 'By PA Sport Staff');
ga('pacontentapi.set', 'dimension2', '81c99a8c-fa86-4e05-a66b-8f3f2ac00c3b');
ga('pacontentapi.set', 'dimension3', 'paservice:sport,paservice:sport:uk');
ga('pacontentapi.set', 'dimension6', 'story');
ga('pacontentapi.set', 'dimension7', 'composite');
ga('pacontentapi.set', 'dimension8', null);
ga('pacontentapi.set', 'dimension9', 'sport:cricket');
ga('pacontentapi.send', 'pageview', { 'location': location.href, 'page': (location.pathname + location.search + location.hash), 'title': 'Murtagh takes five to underpin comfortable Middlesex victory'});