Seamer Mahmood claimed two early wickets and returned to strike twice more.
Saqib Mahmood claimed his first first-class five-for and Matt Parkinson added three wickets as Lancashire won a Roses LV= Insurance County Championship match at Emirates Old Trafford for the first time in 21 years.
Seamer Mahmood claimed two early wickets as Yorkshire slipped to 92 for four, still 258 runs behind, but the visitors resisted until deep into a thrilling evening session.
Mahmood returned to strike twice more and leg-spinner Parkinson claimed the winning wicket when Dom Bess was caught at slip with 40 balls remaining.
Lancashire’s win by an innings and 79 runs keeps them top of Group Three and ensures they have the only unbeaten record in county cricket after four wins in seven games.
They are 26 points clear of Northamptonshire in third place, with Yorkshire only two points clear of the Wantage Road side.
Worcestershire recorded their first victory of the season after beating Derbyshire by an innings and 23 runs at New Road.
Derbyshire resumed the final day on 112 for six and lost their last four wickets in just 8.2 overs as they were dismissed for 128.
Dillon Pennington completed the first five-wicket haul of his career and finished with figures of 14-4-32-5.
It enabled him to enjoy a career-best performance for the second day running after his four for 44 in Derbyshire’s first innings.
He ended with match figures of nine for 76 as Worcestershire claimed 23 points to reignite their hopes of finishing in the top two.
A superb 185 from Australian Test opener Marcus Harris enabled Leicestershire to break their season duck by chasing down 378 to pull off a remarkable come-from-behind victory over Middlesex.
Leicestershire had been 159 in arrears after they were bowled out for 136 but Harris and skipper Colin Ackermann, who made an unbeaten 126, shared a stand of 243 for the third wicket as Middlesex slipped to a sixth defeat – leaving them bottom of Group Two.
Although they suffered some jitters towards the end, Ackermann hit the winning runs to see them home by five wickets to complete the third-highest successful fourth-innings run chase in Leicestershire’s history.
Northamptonshire took just 65 minutes to complete a seven-wicket victory over Sussex.
It was the visitors’ third victory in Group Three this season. Northamptonshire resumed on 131 for two, with Luke Procter 47 not out and Rob Keogh unbeaten on 24, needing another 87 for victory.
Procter reached 50 when he worked Delray Rawlins through midwicket for two, but he had added just one more run to his score when he was out, flailing at a wide delivery from Jamie Atkins for Aaron Thomason to take a good catch low down at first slip.
It was to be the only wicket Sussex took on the final day as the game ended with a flurry of blows, mostly from Saif Zaib, who showed his intentions when he took a step down the wicket and clouted Rawlins over wide mid-on for six.
Amar Virdi finished with four for 96 as Surrey completed an emphatic innings-and-47-run victory against Gloucestershire that propelled them into title contention.
Gloucestershire, starting the final day at the Oval, still 191 runs adrift on 124 for five having been forced to follow on, were dismissed for 268 despite excellent resistance from Jonny Tattersall who remained unbeaten on 86 from 136 balls.
Miles Hammond added only seven runs to his overnight 38 before looking distraught to be given out caught at the wicket for 45, sweeping at Dan Moriarty. The 25-year-old left-hander, who made 77 in the first innings, batted for almost six and a half hours and 280 balls in the game.
Off-spinner Virdi had match figures of seven for 142, while slow left-armer Moriarty added two for 82 to his first innings six for 60.
Surrey’s 22-point win puts them third in Group Two, just six points behind Gloucestershire.
Warwickshire blew Group One wide open after beating Nottinghamshire by 170 runs in a pulsating contest at Edgbaston.
Set a victory target of 309 in 74 overs, the visitors were bowled out for 138 with eight overs to spare as spinner Danny Briggs followed up his important runs in the match with a decisive spell of 24-3-14-36-4.
After the Bears took their overnight 201 for six to 264 all out, they bowled with collective skill to close out a thrilling victory.