Read more about sharing.
Essex fell short in their chase of 264
as Glamorgan beat the Division Two champions by 11 runs at Chelmsford.
Varun Chopra, who recently returned to Essex from Warwickshire, made 79 before the hosts collapsed to 147-5.
Last pair David Masters and Jamie Porter edged Essex close to victory but Michael Hogan (5-45) and Timm van der Gugten (4-56) bowled them out for 252.
Earlier, Mark Wallace was run out for a season’s best of 78 as Glamorgan added three runs to their overnight 293-9.
Essex openers Chopra and Nick Browne (30), who passed 1,000 Championship runs for the season, put on 92 together but the latter’s departure just before lunch preceded a flurry of wickets in the afternoon session.
Masters and Porter were both dropped in quick succession off the bowling of Craig Meschede, but Van der Gugten bowled Porter to clinch a dramatic win for Glamorgan.
During the fourth day’s play, veteran Essex seamer Masters confirmed he is to retire from professional cricket at the end of the season and captain Ryan ten Doeschate extended his contract until the end of 2018.
Meanwhile, Glamorgan announced that first-innings centurion Kiran Carlson was one of four players to agree new deals with the Welsh side.
Glamorgan bowler Michael Hogan told BBC Wales Sport:
“They’re the ones you remember when the wicket’s flat and the sun’s out. It was pretty tough but it’s certainly rewarding to get the win.
“It ebbed and flowed the whole game, but they’re the ones you enjoy playing, we never gave up and in the last hour you get the win, so a fantastic result.
“It’s a little bit of criticism for us that when we come up against the perceived better sides in the league, we seem to be up for it, and against the perceived lesser sides we seem to go in without as much intensity.
“If we can sort that out, we’ll be a force but a great effort from the guys and I can’t fault anyone.”
Find out more
Related to this story
For more ideas, information and inspiration, visit bbc.co.uk/getinspired