Nat Brown gave the underdogs a shock lead when his header looped beyond Conrad Logan after 15 minutes.
Leicester responded well and forced a succession of corners, one of which was powered against a post by Dany N’Guessan.
The Championship club’s pressure paid dividends 10 minutes before the break when Steve Howard’s shot was too hot for Jose Veiga to handle and Robbie Neilson turned home the rebound from close range.
Matty Fryatt struck twice in quick succession at the start of the second half to put Leicester in control.
The first was a curling effort from the left side of the area after 47 minutes and the second came four minutes later when the diminutive striker finished coolly after being put through by Richie Wellens.
Logan produced a fine save to deny Vinny Mukendi just before the hour mark but the substitute striker reduced Macclesfield’s arrears with a header after 64 minutes.
Wellens restored Leicester’s two-goal advantage five minutes later when he drove the ball home from 18 yards.
However, Macclesfield kept plugging away and Colin Daniel made it 4-3 with eight minutes remaining after Logan had parried Richard Butcher’s effort. Gary Simpson’s side could not force an equaliser and Leicester held on.