|LV= County Championship Division One, Aigburth|
|Nottinghamshire 261 & 170-9 beat Lancashire 225 & 205 by one wicket|
|Notts 21pts, Lancs 4pts|
Nottinghamshire moved 11 points clear at the top of Division One with a thrilling one-wicket win at Lancashire.
Usman Khawaja made 53 before Gurney (4-22) took four wickets in 29 balls as the hosts slumped from 99-2 to 140-6, before being dismissed for 205.
Needing 170 to win, Tom Smith took 3-38 and Glen Chapple 3-59 as Notts stumbled to 119-7, before Chris Read (40 not out) and Luke Fletcher (18) put on 44.
Andre Adams could only add six, but last-man Gurney hit the winning run.
Fletcher had batted for 67 minutes to take Notts close, but was caught by Smith off Kabir Ali (2-30).
The same bowler then claimed his 500th first-class wicket as Adams, who had moments earlier smashed a four, skied one to Stephen Parry, before England T20 international Gurney drove Chapple for a single to win the game.
A 21-point haul from the game means Notts move 11 points clear of Somerset, who moved up to second by beating Northants, while Lancashire remain in the Division One relegation zone.
The home side resumed day three on 55-2, leading by only 19 runs, and it took Notts until the 12th over of the day to make the breakthrough, as Khawaja was caught behind by Read.
Steven Croft followed in Gurney's next over for five, before Ashwell Prince (45) and Jos Buttler (25) put on 35 for the fifth wicket to briefly halt Lancashire's demise.
But Gurney struck in successive overs shortly before lunch, trapping Prince leg before with a delivery which kept low and seeing off Smith for a fifth-ball duck, when he edged to Alex Hales at third slip.
Fletcher (3-33) wrapped up the majority of the tail, including Buttler and Kyle Hogg in successive balls, but last-pair Ali (20 not out) and Parry (16) put on 36, before the latter slog-swept Samit Patel to Adams.
The flurry of wickets continued as Notts slipped to 69-4 at tea, needing another 101 to win.
Chapple got rid of Hales, who edged to slip for nine, while Smith accounted for Steven Mullaney (14), Michael Lumb (22) and James Taylor for four.
Croft then took two key catches off Chapple to get rid of Patel (21), who drove to point, and Peter Siddle, who top-edged for a four-ball duck, while Hogg accounted for Riki Wessels (28) in between.
It was left to captain Read to be the mainstay with the bat to guide Notts to their fifth win of the season.
Notts director of cricket Mick Newell:
"We never really made any sort of partnership from the top order and left it to the bottom order.
"Absolutely thrilled to get over the line and get such important points.
"We managed to make a bit of a mess of it but got there in the end."
Lancashire assistant coach Gary Yates:
"We're disappointed because the result hasn't gone our way.
"There wasn't a great deal between the two teams, one team got one more run than the other. It was a great game.
"We know we're a competitive side but we're going to need some wins, that's the reality of it.
"We're confident, the spirit is high and we know exactly what we need to do in the remaining four games."
BBC Radio Nottingham's Robin Chipperfield:
"As last-man Harry Gurney caressed the ball through the covers to win the match, the Notts players on the balcony celebrated as though they had won the Championship.
"Of course they haven't, but you'd have been very tempted to write them off and question their stomach for a title challenge had they lost - chasing 170 to win - against a Lancashire side at the other end of the table.
"Instead Chris Read and Luke Fletcher showed real fighting qualities, as they steered Notts back away from the edge of the cliff.
"Peter Siddle will not be part of the rest of the campaign as he flies back to Australia, but he'll leave wondering whether a Championship medal might be sent via airmail in September."