Nigel Worthington was left to rue a defensive error for Hartlepool's opening goal after York's 2-0 defeat at Victoria Park.
The game was heading for a stalemate until two teenagers struck late on.
It ensured Pools first win of 2014 and inflicted a first loss of the new year on the Minstermen.
Luke James, after 82 minutes, took a knock down from Jack Baldwin and powered home a confident shot into the bottom corner of the net from the edge of the area.
But Jack Barmby stole his thunder seven minutes later.
Signed on Thursday on loan from Manchester United, the attacker had only been on the pitch for 10 minutes when he scored.
The son of former England international Nicky curled a fine shot into the top corner of the net from 20 yards out.
Josh Carson gifted Hartlepool the chance to put the ball into the area for the first goal, and Worthington moaned: "It's hard to take. The performance for 80 minutes was very good, very strong and resilient and we competed - it was a good game overall.
"The situation of how the first goal comes about is disappointing because it's down to indiscipline.
"Josh Carson gives away a stupid free-kick 20 yards from goal when he had the opportunity to clear the ball up the line.
"It's silly. The ball comes into the box and finished up in the back of the net. It knocks the stuffing out of you.
"Then they get a second because their tails are up. So it's how you deal with it."