James Hildreth's third championship century of the season helped Somerset pull off the second highest run chase in their history for a five-wicket victory over Sussex at Hove.
Hildreth finished on 101 not out alongside Peter Trego, who contributed 89 to an unbroken sixth-wicket stand of 166 in 26 overs.
Somerset began the final day on 155-4 in pursuit of 396 having lost three wickets in the final half-hour on the third evening.
Hildreth and Alex Barrow extended their alliance to 80 before Barrow (40) edged behind to give Sussex seamer Steve Magoffin (4-73) his fourth wicket of the innings.
But that was the home side's only breakthrough as Hildreth and Trego guided Somerset across the winning line amid a flurry of attacking strokes.
Hildreth's 180-ball knock contained 15 fours, while Trego took advantage of the County Ground's intimate confines to blast four sixes and 12 fours in his 72-ball effort.
The win puts Somerset in pole position to finish second in the Division One table, one point above Sussex but 40 behind already-crowned champions Warwickshire heading into the final week of the season.
Somerset suffered a late collapse in the pursuit of a victory target of 396 against Sussex, who are now just playing for pride after Warwickshire clinched the Divison One title.
Marcus Trescothick (71) and opening partner Arul Suppiah (70) seemed to have the hosts on course with a stand of 147 for the first wicket at Hove.
However both departed in the space of seven balls and with Chris Jones and nightwatchman Steve Kirby being dismissed by Steve Magoffin (3-15), Somerset closed on 155-4, still needing another 241.
Sussex had lost a flurry of wickets themselves earlier in the day, slumping from their overnight position of 186-2 to 308 all out.
Centurion Chris Nash was the first to depart for 126 as the hosts surrendered six wickets in 15 overs for 40 runs. Murray Goodwin was another to go, falling 23 short of a hundred in his final appearance for the county.
The ex-Zimbabwe batsman was one of Alfonso Thomas's victims as the Somerset paceman picked up 5-68 - his second five-wicket haul of 2012.
Sussex took charge of their game against Somerset on day two to maintain a distant hope of nicking the Division One title.
The home side dismissed Somerset for 134 to take a first-innings lead of 87, and by the close Chris Nash's unbeaten hundred had helped them to 186-2 in their second innings.
An overall lead of 273 left second-placed Sussex well-placed to capitalise should Warwickshire fail to close out victory over Worcestershire in their penultimate fixture.
But with the Bears well in command at new Road, it is likely the best Hove can hope for is a fairytale farewell for Murray Goodwin.
The long-serving batsman - playing his final match at the ground - finished the day 51 not out having shared 139 with Nash, whose chanceless 106 featured 17 fours and took him to within 66 of 1,000 Division One runs.
Earlier, Somerset failed miserably to build on a 62 second-wicket stand between Chris Jones and Marcus Trescothick, who passed 20,000 first-class runs before he was trapped by Steve Magoffin with the score on 68.
That precipitated the fall of 9 wickets for 66 runs as six were shared by seamers Steve Magoffin and Lewis Hatchett, and Monty Panesar finished with 3-15 from 13 overs.
Sussex's County Championship title hopes started to slip away on day one against Somerset at Hove.
The hosts came into their penultimate game 22 points behind leaders Warwickshire but a first innings total of 221 meant they collected just one batting bonus point.
The Bears, meanwhile, dismissed Worcestershire for 60 at New Road and will be crowned champions if they score 350 in their first innings and go on to win the match.
Beaten in the semi-finals of both the T20 and CB40, Sussex desperately needed a confidence boost, but from the moment Ed Joyce lost the toss the day belonged to Somerset.
Wickets fell regularly despite the best efforts of skipper Joyce, who top-scored with 65, and his opposite number Marcus Trescothick took five slip catches.
Abdur Rehman's slow left-arm yielded 3-30 while the seamers shared the remaining seven wickets - Alfonso Thomas taking his three in a 15-ball spell just before tea.
Murray Goodwin made 16 and has just one more chance to sign off his last game at Hove in style after announcing his imminent retirement on the eve of play.
Somerset lost Arul Suppiah as they began their reply, but Trescothick and Chris Jones took them to 30-1 by stumps.