Northamptonshire came up just short as they had to settle for a draw in the end as their game at Glamorgan went right down to the final over.
Glamorgan started the day on 181-3 still needing 119 just to avoid an innings defeat, but Stewart Walters hit a century and Mark Wallace 54 as they hosts made 448 and set Northants 149 to win off 23 overs.
The divisions two leaders made shaky progress and eventually left themselves needing 14 off the final over, which then turned to nine off the last two balls to grab the win.
However, Graham Wagg bowled Andrew Hall with the penultimate ball and Glamorgan had managed to earn a draw which had looked so far out of their grasp.
Half-centuries from Alviro Petersen and Will Bragg ensured Glamorgan took their LV= County Championship match against Division Two leaders Northamptonshire into the final day at Swansea.
The visitors are still firm favourites to secure a sixth win of the season after declaring their first innings on 552-9 - the biggest score by a county side at the St Helen's ground - having lost four wickets before lunch.
Stephen Peters moved on to 222 before he cut a short, wide James Harris ball straight to Stewart Walters at point, while Andrew Hall departed for 64 after being trapped lbw by Jim Allenby.
The home side needed 300 to avoid a second consecutive innings defeat against Northamptonshire and despite losing Gareth Rees to just the 10th ball of the innings, skipper Petersen (75) and Bragg (69) ensured that Glamorgan were able to fight another day.
Petersen appeared set for a century until he was adjudged leg before attempting to sweep Paul Best, while Bragg then became the third batsman to be dismissed leg before, this time by James Middlebrook.
By the close Glamorgan had reached 181-3 and need a further 119 to make Northants bat again.
An unbeaten 204 from opener Stephen Peters to put Northamptonshire firmly in the driving seat of their County Championship clash against Glamorgan.
The visitors notched up a first innings lead of 182 with six wickets remaining after Peters and captain Andrew Hall shared in an unbeaten partnership for the fifth wicket, ending the day on 434-4.
Resuming on 67 without loss, a deficit of 185, Mal Loye and Peters extended their opening partnership to reach their first century opening stand of the season.
Loye fell on 61, caught off Robert Croft, but Glamorgan could not make another breakthrough until after lunch when Dean Cosker bowled Rob White for 30.
Alex Wakely made a rapid 27-ball 38 before he became Cosker's second victim when he was stumped by wicketkeeper Mark Wallace.
James Harris had Rob Newton well caught, low down at cover for 34, to bring skipper Hall to the crease. He will begin day three unbeaten on 54.
Off-spinner James Middlebrook claimed his best figures for Northamptonshire as the visitors dominated the first day against Glamorgan at Swansea.
The Division Two leaders bowled Glamorgan out for 252, with Middlebrook taking 4-63 in 17 overs. Only Stewart Walters, with 81 not out, offered any real resistance for the Welsh county.
After reaching 93-3 at lunch Glamorgan proceeded to lose seven wickets in the afternoon session.
Jim Allenby clipped a ball straight to mid-wicket for the first of Middlebrook's four wickets, while Mark Wallace went leg before playing round his pad, James Harris was bowled behind his legs and Graham Wagg was stumped.
Chaminda Vaas returned to remove Robert Croft and Dean Cosker, leaving Walters stranded on 81 after nearly three hours in the middle. He faced 132 balls and hit seven fours and two sixes.
In reply, Northamptonshire openers Stephen Peters (28) and Mal Loye (35) took their side to 67 without loss at the close.
Peters and Loye both played sensibly and also prevented James Harris, the England Lions seamer, from taking his 200th first-class victim. Just before the close Loye survived a confident leg before appeal by Cosker.