Cardiff were given a scare in the second round of the Carling Cup by Macclesfield before seeing off their League Two visitors at Ninian Park.
Joe Ledley celebrates scoring Cardiff's equaliser
The Silkmen stunned Cardiff after just five minutes when a quick break down the left let Martin Bullock score.
The Championship side levelled after the break when Joe Ledley smashed in goalkeeper Alan Fettis' weak punch out.
Jason Koumas completed Cardiff's comeback with a sublime free-kick, curling into the top right of the goal.
Cardiff manager Dave Jones:
Macclesfield were up for the game, but we played at a tempo that wasn't going to hurt them in the first half.
We made life difficult for ourselves, we got caught because we were sloppy and the lad (Martin Bullock) put it away well.
But we squeezed them in the second half, got the equaliser and then Jason Koumas' goal is top draw - well worth the admission fee just for that.
Macclesfield manager Brian Horton:
"We scored a tremendous goal early on with some very neat football - we kept them out and the home side were booed off at half-time.
"Unfortunately for us they scored too soon after the break and the winning goal was pure quality - there is nothing anyone can do about a strike like that.
"Our priority is the league and when we get our strikers back we should see an improvement in our position."
Cardiff: Margetson, Weston, Purse, Cox, Barker, Ardley, Ledley, Whitley, Parry (Koumas 72), Lee, Fleetwood (Ferretti 62).
Subs Not Used: Alexander, Darlington, Mulryne.
Goals: Ledley 50, Koumas 81.
Macclesfield: Fettis, Sandwith, Morley, Swailes, Barras (Beresford 83), Briscoe, Bullock, McIntyre, Whitaker, Harsley, Miles.
Subs Not Used: Townson, Deasy, Smart, Brightwell.
Goals: Bullock 5.
Ref: P Melin (Surrey).