The hosts were the better side from the first whistle at Boundary Park and could have been in front two minutes after it, but Richard Wood volleyed straight at keeper Dean Bouzanis after he flapped at a corner.
Matt Smith squandered Oldham's best chance of the first half when one-on-one with City keeper Joe Murphy, firing straight at his feet.
Stephen Elliott put City in front on the hour mark, five minutes after coming off the bench. Gary McSheffrey's left-wing cross reached the stooping striker at the back post and he headed in.
Elliott thought he had added an identical second 15 minutes later but it was judged not to have crossed the line.
Smith then leapt highest from an 89th-minute corner to notch what he thought was the final goal, but the Sky Blues kept pushing and when a deep cross found its way to Bailey he lashed home a powerful volley.