The match seemed to be heading for a 1-1 draw when City were awarded a free-kick 20 yards out and although Notts goalkeeper Steve Mildenhall parried the effort it fell invitingly for visiting midfielder Brian Tinnion.
Tinnion, on his 500th City appearance, used his skill and experience to flight the ball into the path of Goodfellow who ensured all three points - and the double over Notts - went to City.
It was quite a day for Goodfellow, signed in the week for £100,000 from Stoke City and brought off the bench to miss one golden chance before he found the net in stoppage time.
City were the better footballing side throughout but Notts, inspired by new manager Gary Mills, battled more bravely than in most recent games and probably felt they deserved to get something out of the contest.
Lee Peacock had given City an early lead with a smart finish when he squeezed between two Notts defenders in fastening on to a long clearance.
Just before half-time Notts enjoyed a slice of luck to get back on terms.
Paul Bolland whipped in a dangerous cross from the right and visiting defender's Tony Butler's glancing header took it away from City goalkeeper Steve Phillips.
City had other chances particularly in the second half from which they failed to deliver and their joy at the end was plain to see.
Mills said that he was pleased with the way Notts had fought and would be on the training ground with his new players on Monday to sort out some problems which had been apparent to him.
City manager Danny Wilson said the fact that they had only been beaten four times showed both how consistent they were and a never say die spirit - hence the late winner.