Accrington striker Roscoe D'Sane scored twice as Macclesfield's unbeaten away record was ended in thrilling style.
Both sides hit the woodwork in the first half before D'Sane broke the deadlock with a fine solo goal.
D'Sane set up Paul Mullin to make it 2-0 before Kevin McIntyre pulled one back for Macclesfield from the spot after Graham Branch fouled Rob Green.
Adam Murray set up Gareth Evans to nod home an equaliser but D'Sane won it for Stanley with a close-range header.
Att: 1,792