Romone Rose scored a late winner to edge Newport County away from the Blue Square Bet Premier relegation zone against play-off hopefuls York City.
Nat Jarvis put the home side ahead when he poked in Sam Foley's in-swinging corner from a yard out.
The lead lasted six minutes as Patrick McLaughlin arrowed a free-kick into the bottom corner but Rose set himself up for the winner 20 minutes from time.
Newport's victory means bottom club Bath City are relegated.
York, who arrived in Newport unbeaten in their last 13 away games in the league, stay above Southport on goal difference in fourth place.
County move up to two places to 18th and four points clear of the bottom four.
VIEWS FROM THE DRESSING ROOM
Newport County manager Justin Edinburgh told BBC Radio Wales:
"It's a fantastic result against an excellent side that have one of the best away records this season.
"I thought the boys were outstanding in terms of character and I'm delighted with them.
"It gives us a real good chance of survival."
York City manager Gary Mills told BBC Radio York:
"It was a poor game. It's rock-hard, slippy and difficult to play on but they probably played it better than us.
"They won second balls in there and turned us and put us under pressure.
"Having said that, until they scored they weren't hurting us at all second half. We were dealing with it."