Aron Gunnarsson scored twice as Cardiff secured a win over Barnsley in a thrilling game in the Championship.
Kenny Miller opened the scoring for Cardiff on 10 minutes before substitute Joe Mason's rebound made it 2-0.
Danny Drinkwater pulled one back from a free-kick only for Gunnarsson to volley Cardiff two goals ahead once more.
Second-half goals from Don Cowie and Gunnarsson looked to have wrapped up the win but Jimmy McNulty and Ricardo Vaz Te goals set up a nervy finale.
Cardiff made a lively start with Gunnarsson firing over the crossbar before Ben Turner tested Luke Steele from long range.
And it was the home side who took the lead on 10 minutes with the returning Miller slotting home following Cowie's pass.
Cardiff continued to control the game and an instinctive save from Steele denied Miller's powerful header following Peter Whittingham's corner.
Miller's involvement was soon to end as he was forced off the field with a head injury after colliding with team-mate Turner, with Joe Mason the replacement.
Mason was in the thick of the action almost immediately and the former Plymouth striker was fouled on the edge of the area by Rob Edwards.
Whittingham's free-kick was parried by the keeper before Mason followed up to score with rebound.
Within two minutes Barnsley has pulled a goal back with former Bluebird Drinkwater's long-range free-kick took a deflection past David Marshall.
However during a frantic spell Cardiff re-established their lead within two minutes with Gunnarsson scoring with a stunning strike on the volley from 20-yards following Whittingham's cross-field pass.
Drinkwater, who spent last season on loan at Cardiff, struck the bar with a free-kick shortly after the interval but it was the home side who extended their lead on the hour mark.
Cowie latched on to Mason's through-ball before rounding Steele to make it 4-1.
Iceland international Gunnarsson added a fifth from close range after collecting Andrew Taylor's pass in the 71st minute.
It seemed Cardiff had done enough to secure the victory but they had to withstand a late Barnsley fightback.
McNulty headed home from Jacob Butterfield's right-wing cross in the 82nd minute before Vaz Te scored their third four minutes later when he fired home from substitute Craig Davies' lay-off.
But Malky Mackay's side held on to end their three-game winless run in the Championship.
- 01 Marshall Booked
- 02 McNaughton
- 03 Taylor
- 05 Hudson
- 25 Turner
- 07 Whittingham
- 08 Cowie
- 11 Conway (Kiss - 66' )
- 17 Gunnarsson
- 37 McPhail (Earnshaw - 77' )
- 09 Miller (Mason - 29' )
- 22 Heaton
- 06 Gerrard
- 04 Kiss
- 10 Earnshaw
- 20 Mason
- 01 Steele
- 04 Edwards Booked (McEveley - 46' )
- 06 Foster
- 14 Wiseman
- 15 McNulty
- 05 Doyle
- 08 O'Brien (Davies - 46' )
- 11 Perkins (Vaz Te - 46' )
- 19 Butterfield
- 20 Drinkwater
- 27 Gray Booked
- 12 Preece
- 03 McEveley
- 17 Addison
- 09 Davies
- 18 Vaz Te
Live Text Commentary
Full Time The referee brings the game to a close.90:00 +1:56
Effort from the edge of the box by Filip Kiss goes wide of the left-hand upright.90:00 +1:02
Free kick awarded for an unfair challenge on Ricardo Vaz Te by Kevin McNaughton. Free kick crossed left-footed by Jay McEveley from left wing, clearance by Mark Hudson.88:10
Robert Earnshaw takes a shot from 12 yards. Save by Luke Steele.85:56
The assist for the goal came from Craig Davies.85:56 Goal scored
Goal! - Ricardo Vaz Te - Cardiff 5 - 3 Barnsley A goal is scored by Ricardo Vaz Te from deep inside the penalty area to the bottom left corner of the goal. Cardiff 5-3 Barnsley.83:30
Jacob Butterfield produces a right-footed shot from just outside the area that goes wide left of the goal.81:59
The referee blows for offside. David Marshall takes the free kick.81:14
The assist for the goal came from Jacob Butterfield.81:14 Goal scored
Goal! - Jimmy McNulty - Cardiff 5 - 2 Barnsley Jimmy McNulty grabs a headed goal from close range. Cardiff 5-2 Barnsley.80:40
Inswinging corner taken by Jacob Butterfield,79:31
The referee blows for offside against Andrew Taylor. Luke Steele takes the indirect free kick.78:23
Free kick awarded for a foul by Jacob Butterfield on Don Cowie. Free kick taken by Don Cowie.76:23 Substitution
Substitution Stephen McPhail goes off and Robert Earnshaw comes on.75:44
Joe Mason takes a shot. Save made by Luke Steele.72:04
The referee blows for offside. Nathan Doyle takes the free kick.70:20
Assist on the goal came from Andrew Taylor.70:20 Goal scored
Goal! - Aron Gunnarsson - Cardiff 5 - 1 Barnsley A goal is scored by Aron Gunnarsson from close range low into the middle of the goal. Cardiff 5-1 Barnsley.67:29
Foul by Filip Kiss on Jacob Butterfield, free kick awarded. Free kick taken by Stephen Foster.66:15
Unfair challenge on Kevin McNaughton by Ricardo Vaz Te results in a free kick. David Marshall takes the direct free kick.
Substitution Filip Kiss replaces Craig Conway.62:59
Foul by Aron Gunnarsson on Craig Davies, free kick awarded. Free kick taken by Nathan Doyle.59:34
Joe Mason provided the assist for the goal.59:34 Goal scored
Goal! - Don Cowie - Cardiff 4 - 1 Barnsley Don Cowie fires in a goal from inside the six-yard box to the bottom left corner of the goal. Cardiff 4-1 Barnsley.59:15
Joe Mason takes a shot. Save made by Luke Steele.58:20
Corner from left by-line taken by Jacob Butterfield.58:01
Ben Turner takes a shot. Luke Steele makes a save.57:42
Corner taken short by Craig Conway.56:14
Daniel Drinkwater challenges Aron Gunnarsson unfairly and gives away a free kick. Andrew Taylor takes the direct free kick.54:18
Inswinging corner taken from the right by-line by Peter Whittingham, clearance by Stephen Foster.51:13
Ricardo Vaz Te takes the direct free kick. Daniel Drinkwater takes a shot from close in clearing the crossbar.51:13 Booking
Booking Andy Gray is given a yellow card.51:11 Booking
Booking David Marshall goes into the referee's book for dissent.47:59
Scott Wiseman concedes a free kick for a foul on Craig Conway. David Marshall takes the indirect free kick.46:23
Corner from the right by-line taken by Peter Whittingham, Jay McEveley manages to make a clearance.46:06
Don Cowie takes a short corner.45:01
The referee blows his whistle to start the second half.45:01 Substitution
Substitution Craig Davies joins the action as a substitute, replacing Jim O'Brien.45:01 Substitution
Substitution Ricardo Vaz Te is brought on as a substitute for David Perkins.45:01 Substitution
Substitution Jay McEveley replaces Rob Edwards.45:00 +3:21 Half time
Half Time The ref blows to signal half-time.45:00 +1:37
Inswinging corner taken by Jacob Butterfield, Joe Mason manages to make a clearance. Jim O'Brien takes a shot. Peter Whittingham gets a block in.45:00 +0:32
Don Cowie takes a shot. Luke Steele makes a save.45:00 +0:15
Don Cowie takes a short corner.42:46
Effort on goal by Aron Gunnarsson from deep inside the area goes harmlessly over the bar.42:10
Corner taken short by Peter Whittingham.40:39
The assistant referee flags for offside against Joe Mason. Stephen Foster takes the indirect free kick.37:39
Assist on the goal came from Peter Whittingham.37:39 Goal scored
Goal! - Aron Gunnarsson - Cardiff 3 - 1 Barnsley Aron Gunnarsson gets on the score sheet with a goal from just outside the penalty box to the bottom right corner of the goal. Cardiff 3-1 Barnsley.35:20
Andy Gray provided the assist for the goal.35:20 Goal scored
Goal! - Daniel Drinkwater - Cardiff 2 - 1 Barnsley Daniel Drinkwater finds the net with a goal direct from the free kick from long range to the bottom left corner of the goal. Cardiff 2-1 Barnsley.35:03
Free kick awarded for a foul by Mark Hudson on Andy Gray.33:49
Assist on the goal came from Peter Whittingham.33:49 Goal scored
Goal! - Joe Mason - Cardiff 2 - 0 Barnsley Joe Mason finds the net with a goal from close in low into the middle of the goal. Cardiff 2-0 Barnsley.33:08
Peter Whittingham fires a strike on goal direct from the free kick, save by Luke Steele.33:08 Booking
Booking The referee cautions Rob Edwards for unsporting behaviour.31:39
Joe Mason fouled by Rob Edwards, the ref awards a free kick.31:03
The assistant referee signals for offside against Andy Gray. David Marshall restarts play with the free kick.30:11
Nathan Doyle takes a shot. Blocked by Mark Hudson.27:55
Peter Whittingham shoots direct from the free kick.27:55 Substitution
Substitution (Cardiff) makes a substitution, with Joe Mason coming on for Kenny Miller.27:55
Stephen McPhail fouled by David Perkins, the ref awards a free kick.25:53
Inswinging corner taken left-footed by Peter Whittingham, clearance by Jim O'Brien.25:15
Inswinging corner taken by Peter Whittingham, Kenny Miller takes a shot. Save made by Luke Steele.24:44
Foul by Jimmy McNulty on Craig Conway, free kick awarded. Peter Whittingham takes the direct free kick.21:42
The official flags Kenny Miller offside. Indirect free kick taken by Luke Steele.17:58
Free kick awarded for an unfair challenge on Craig Conway by Jimmy McNulty. Direct free kick taken by Mark Hudson.16:47
Jim O'Brien is caught offside. Andrew Taylor restarts play with the free kick.15:59
Inswinging corner taken right-footed by Don Cowie from the left by-line to the near post, clearance by Rob Edwards.13:10
Rob Edwards gives away a free kick for an unfair challenge on Craig Conway. David Marshall restarts play with the free kick.9:51
Assist by Don Cowie.9:51 Goal scored
Goal! - Kenny Miller - Cardiff 1 - 0 Barnsley A goal is scored by Kenny Miller from close range to the bottom right corner of the goal. Cardiff 1-0 Barnsley.8:55
Inswinging corner taken right-footed by Kenny Miller from the left by-line, save made by Luke Steele.5:45
Scott Wiseman produces a left-footed shot from just outside the box that misses to the right of the net.5:00
Ben Turner takes a shot. Save by Luke Steele.3:40
Strike by Aron Gunnarsson from inside the six-yard box clear the bar.3:03
Jim O'Brien gives away a free kick for an unfair challenge on Andrew Taylor. Andrew Taylor takes the free kick.0:46
Kevin McNaughton challenges David Perkins unfairly and gives away a free kick. Jimmy McNulty restarts play with the free kick.0:00
The game begins.
Live data and text provided by our data suppliers