Kevin McNaughton provided the inspiration for Cardiff as they edged past League Two outfit Hereford to progress to the fifth round of the FA Cup.
The Scottish defender produced a fine volley to break the deadlock in first-half injury-time and won a penalty which Steve Thompson converted in the 67th minute to give the Bluebirds a two-goal advantage.
Theo Robinson pulled a goal back for Graham Turner's side with 13 minutes left but the Coca-Cola Championship outfit held on to secure their place in the last 16.
Hereford - who hoped to make the fifth round for the first time in their history - are 44 places below the Bluebirds in the league standings and were backed by a vociferous crowd.
But it was Cardiff - who overcame non-league Chasetown in the third round - that dominated the early exchanges yet initially struggled to make the breakthrough their dominance deserved.
Dave Jones' side, who arrived at Edgar Street with a seven-game unbeaten record, could have been ahead inside the second minute.
Paul Parry collected possession on the edge of the 18-yard box and hit a rasping shot which produced a good save from Hereford goalkeeper Wayne Brown.
The Bulls sought a breakthrough of their own in the sixth minute when Simon Johnson connected with a cross by Trent McClenahan but fired wide from 12 yards.
Hereford striker Trevor Benjamin then caused havoc in the visiting rearguard with a left-foot shot which flashed narrowly wide from 12 yards.
It was Cardiff though who posed the biggest threat and went close again in the 12th minute.
An outswinging corner from left was met by the head of Joe Ledley, but Brown was again on hand to make a smart stop.
Moments later Parry was booked for unsporting behaviour before he fired wide from 12 yards in the 18th minute.
The momentum swung towards Hereford as the half wore on and on the half-hour mark, Robinson's 25-yard shot drew an impressive stop from Cardiff goalkeeper Michael Oakes.
Kris Taylor also went close for the Bulls but McNaughton's superb volley shortly before the half-time whistle handed Cardiff a slender advantage at the interval.
Hereford came close to an equaliser three minutes after the half-time break when Oakes was forced to save a close-range header from Lee Collins.
Thompson then had a shot saved by Brown in the 56th minute but 13 minutes later he was able to double Cardiff's lead after Clint Easton brought down McNaughton in the penalty area.
Thompson took the resulting spot-kick and sent goalkeeper Brown the wrong way as he calmly slotted the ball into the bottom-right corner of the net.
Hereford were handed a lifeline in the 77th minute when Robinson collected Ben Smith's pass and fired the ball into the bottom-left corner.
Turner's side pushed hard for an equaliser in the remaining time, including seven minutes of added time, but it was Cardiff who came closest to scoring when Ledley screwed his shot wide.
Teams
Hereford Brown, McClenahan, Beckwith, Collins, Rose, Johnson,Smith, Diagouraga, Taylor (Easton 65), Benjamin (Gwynne 71),Robinson.
Subs Not Used: Ingham, McCombe, Palmer.
Booked: Robinson.
Goals: Robinson 77.
Cardiff Oakes, McNaughton, Johnson, Loovens, Capaldi,Whittingham, McPhail, Rae, Ledley, Parry,Thompson (Hasselbaink 88).
Subs Not Used: Enckelman, Purse, Ramsey, Blake.
Booked: Parry.
Goals: McNaughton 45, Thompson 67 pen.
Att: 6,855
Ref: Andy D'Urso (Essex).