The ex-Aberdeen centre-back struck from a corner after 86 minutes, forcing in from close range after a downward header from Jean Yves M’voto.
County had made the breakthrough on 10 minutes when former Oldham striker Lee Hughes deflected in Hamza Bencherif’s shot with a two-yard header.
Oldham pulled level after 26 minutes as Luca Scapuzzi took Dean Furman’s pass, danced through the visiting defence and rounded keeper Stuart Nelson before converting from six yards.
County were back in front after 39 minutes when Oldham lost the ball cheaply and Neal Bishop hit a 20-yard drive which deflected over stranded keeper Alex Cisak.
But the Latics equalised again through substitute Filipe Morais, whose 70th-minute cross evaded a crowd of players and bounced in off the far post. Diamond sealed the fightback and Chris Taylor almost added a fourth.