City made the trip to Accrington Stanley's ground for the away fixture against Rochdale, and Kevin Townson put 'Dale in front in the first half.
City had the upper hand in the second half however, hitting the woodwork three times before getting the equaliser 20 minutes from time, with youngster Steve Burton heading in a corner.
Gary Bradshaw then headed home Ben Morley's cross for the winner.
City are two points behind leaders Macclesfield, each with a game left to play. If City win at bottom-of-the-league Halifax and the Silkmen fail to beat mid-table Hartlepool, the Avon Insurance Division 3 trophy will be coming to Boothferry Park.
City line-up: Glennon; Morley, Peat, Burton, Holt; Matthews, Kerr, Whitmore, Beresford; Rowe, Bradshaw.
Subs: Bowsley, Tomlinson, Turnbull, Kaveney, Crutwell.