Gillingham slumped to a fifth consecutive defeat after being outfoxed by a dogged Newport County side who ended their own three-game losing run.
The visitors led 2-0 at half-time at Priestfield Stadium through Matt Baker's volley and Kyle Hudlin's turn-and-shot.
Gillingham dominated the second half, pinning the Exiles back in their own half, but were unable to find a way past the excellent Nick Townsend in the visitors' goal.
After a slump in form that has seen them match their worst losing streak since 2021, Gillingham drop out of the League Two play-off places - falling from sixth to 11th - while Newport climb from 15th to 13th, just a point now behind the Gills.
Jayden Clarke had a gilt-edged chance to give Gillingham an early lead but the right winger's shot back across goal went agonisingly just wide of the far post.
Instead Baker put Newport ahead when Anthony Glennon's free-kick from the right found him lurking at the back post, and the defender volleyed a fine right-foot strike back into the far top corner of the net.
Gillingham suffered a further setback when George Lapslie limped off after just 21 minutes, to be replaced by Wales midfielder Jonny Williams.
The home side pushed to get back on level terms against a solid Exiles rearguard, but were undone for the second time by a swift counter-attack.
Baker gathered a loose ball and strode almost to the halfway line before finding Bobby Kamwa galloping down the right, with the winger firing in a low first-time cross.
Hudlin collected with his back to goal before the 6ft 9in striker's deft touch out of feet allowed him to swivel and strike the ball into the bottom corner.
On the stroke of half-time Gillingham were awarded a free-kick just on the edge of Newport's area, but Timothée Dieng could only find the wall from that promising position.
Gillingham returned from the dressing room fired up and Jack Nolan just failed to connect from close range, while Ethan Coleman's first-time volley sailed narrowly over the crossbar as Newport creaked.
The pressure increased and Townsend had to be at his best to save point-blank from Marcus Wyllie after he was put through by Dien's cute flick.
Townsend again came to Newport's rescue when the Antigua and Barbuda international threw out an instinctive right hand to block Williams' low shot.
Joseph Gbode had one last real chance to turn Gillingham's dominance into a goal, but the substitute could not keep his header down from Williams' free-kick.
Newport County manager Nelson Jardim told BBC Sport Wales:
"I'm very, very satisfied with that, I would say this win goes entirely to the fans. I know they've been disappointed, especially the last game, but I think they deserve this win.
"It's just over 100 fans we had here tonight, with a lot of travel, so thanks for their support.
"We knew this match would be tough... but this was the game to bounce back, the boys showed that, showed the character we need, and again we've probably been a little bit too much criticised for conceding goals.
"Coming up here and defending like we did, especially towards the end of the game, was just brilliant - everyone was up there at their best and we now have to build on this win."