James Collins came off the bench as Cardiff claimed a much-needed 2-1 Championship victory over Preston.
In a genuine game of two halves, the home side were dominant in the first and ended up rueing missed chances that should have seen them more than just the one goal up at the break.
Straight from kick-off, Emil Riis Jakobsen broke free and played a ball back to Ali McCann who had his shot deflected for a corner.
Another corner followed straight after, with Ryan Ledson curling an effort into the danger area and Sean Maguire popping up at the far post to steer the ball home.
It was just the start North End needed after a heavy 3-0 defeat last time out at Nottingham Forest. They continued to press, Maguire laying off for Tom Barkhuizen, who saw his shot well blocked.
The Bluebirds - roared on by their passionate travelling support - came close as Aden Flint headed a chance just wide from a Ryan Giles cross.
Preston were by far the better team and soon after McCann stung the palms of Alex Smithies, who made a smart save from a shot that was destined for the top corner.
Cardiff's discipline was letting them down with the game punctuated by free-kicks conceded by the visitors, allowing Preston to retain control.
The contrast was so stark that Preston conceded their first free-kick just before half-time, by which time Cardiff had conceded nine.
Collins replaced Chanka Zimba at half-time for Cardiff and nearly made an immediate impact. Giles' low ball was cleverly flicked into the path of the substitute by Rubin Colwill and Collins fired just wide.
Moments later Will Vaulks smashed a low effort against the foot of the post as Steve Morison's men started the second half a different outfit.
And they got their rewards when Vaulks swung a free-kick into the penalty area and Mark McGuinness wanted it more than the Preston defenders, beating Daniel Iversen with a downward header.
Ledson came close to regaining the lead for Preston, his shot from the edge of the area turned around the post by Smithies.
That was the sum total of Preston's second-half efforts as it was the Bluebirds who were now dominant.
Another substitute Mark Harris should have done better than having his close-range effort deflected for a corner.
But from that corner, Giles swung the ball in and Collins' header found the back of the net. It was a goal that was inevitable, right in front of the delirious away fans.
It earned Cardiff a vital three points, putting distance between themselves and the relegation zone, dragging Preston back into that mix.
Preston North End: Iversen, Van Den Berg, Bauer, Hughes, Cunningham (Earl 68’), McCann, Ledson (Sinclair 68’), Browne, Barkhuizen, Maguire (Johnson 77’), Riis.
Subs not used: Hudson, Lindsay, Storey, Potts.
Cardiff City: Smithies, Ng, McGuinness, Nelson, Flint, Giles, Pack, Vaulks, Colwill (Bacuna 87’), I. Davies (Harris 62’), Zimba (Collins 46’).
Subs not used: Phillips, Morrison, Brown, Sang.