The hosts were closest to scoring in a cagey first half as Peter Whittingham's thunderous long-range shot hit the bar.
Gunnarsson won it for Cardiff with a swerving first-time effort from 25 yards, though Apostolos Vellios almost equalised but also hit the woodwork.
Forest drop to 21st place in the Championship table, just one point above the bottom three.
Cardiff, meanwhile, climb up to 13th after a third successive home win.
A significant day at the foot of the Championship saw four of Forest's relegation rivals taking each other on, with Blackburn hosting Bristol City and Birmingham at home to Burton.
Perhaps mindful of how tight things were in the bottom half, Mark Warburton's side started a little apprehensively against Cardiff, who were the first to threaten with Whittingham's booming 30-yard shot which crashed against the crossbar.
Other than that and a powerful long-range effort from Forest's Mustapha Carayol, there was precious little in terms of scoring opportunities in the first half.
There was more entertainment near the dugout, where Cardiff assistant manager Kevin Blackwell and his opposite number David Weir had to be separated after frayed tempers almost led to a scuffle.
Forest appeared to harness that emotion at half-time, emerging after the restart with renewed vigour and attacking intent.
Carayol looked their likeliest source of a goal, unnerving the home defence with his direct and quick running.
Despite the visitors' improvement, it was Cardiff who made the breakthrough as Kadeem Harris' cross was only half-cleared, leaving the ball to bobble invitingly into the path of Gunnarsson, who unleashed a fierce first-time shot which swerved beyond Jordan Smith and into the far corner.
Forest rallied, with substitutes Vellios and Britt Assombalonga threatening - but the former wasted their best opportunity as his looping header bounced on to the bar, stretching their winless run away from home to 11 league games.
Cardiff City manager Neil Warnock:
"Gunnar normally whacks the pigeon off the top of the stand with those strikes. It was like a missile going into the top corner.
"I watched it all the way in and the goalkeeper had no chance. It was a cracking finish. I think he can do more in attack and should be pushing for 10 goals a season, but I'm delighted.
"I know people have said we've got nothing to play for, but we wanted to have a real go and I think we did that."
Nottingham Forest manager Mark Warburton:
"We created some good chances to score, but I'm disappointed we conceded a goal from 25 yards because I thought we did more than enough to get a point.
"We are where we are and I'm not getting away from that. But if we play like we did today and show the desire and work ethic we did, then we'll be okay. I hope the supporters saw that in our performance because this is a very tough place to come.
"We have to concentrate on ourselves now because if you don't do that in this league, you pay the price."
Match ends, Cardiff City 1, Nottingham Forest 0.
Second Half ends, Cardiff City 1, Nottingham Forest 0.
Attempt missed. Eric Lichaj (Nottingham Forest) header from the centre of the box misses to the left. Assisted by Mustapha Carayol with a cross.
Offside, Cardiff City. Kenneth Zohore tries a through ball, but Junior Hoilett is caught offside.
Attempt blocked. Kenneth Zohore (Cardiff City) right footed shot from the centre of the box is blocked. Assisted by Joe Bennett.
Foul by David Vaughan (Nottingham Forest).
Kadeem Harris (Cardiff City) wins a free kick on the left wing.
Offside, Cardiff City. Greg Halford tries a through ball, but Junior Hoilett is caught offside.
Foul by Apostolos Vellios (Nottingham Forest).
Sean Morrison (Cardiff City) wins a free kick in the defensive half.
Joe Worrall (Nottingham Forest) wins a free kick in the defensive half.
Foul by Kenneth Zohore (Cardiff City).
Attempt blocked. Apostolos Vellios (Nottingham Forest) right footed shot from outside the box is blocked. Assisted by Zach Clough.
Daniel Fox (Nottingham Forest) wins a free kick in the defensive half.
Foul by Kenneth Zohore (Cardiff City).
Foul by Apostolos Vellios (Nottingham Forest).
Greg Halford (Cardiff City) wins a free kick on the left wing.
Attempt missed. Junior Hoilett (Cardiff City) right footed shot from the centre of the box is close, but misses the top right corner. Assisted by Joe Bennett.
Substitution, Cardiff City. Greg Halford replaces Peter Whittingham.
Attempt missed. Britt Assombalonga (Nottingham Forest) left footed shot from the centre of the box is high and wide to the left. Assisted by Ben Osborn.
Attempt blocked. Ben Osborn (Nottingham Forest) left footed shot from the right side of the box is blocked.
Attempt blocked. Chris Cohen (Nottingham Forest) left footed shot from outside the box is blocked. Assisted by Ben Osborn.
Apostolos Vellios (Nottingham Forest) hits the bar with a header from very close range. Assisted by Mustapha Carayol with a cross.
Attempt missed. Aron Gunnarsson (Cardiff City) right footed shot from outside the box is too high. Assisted by Kadeem Harris.
Foul by David Vaughan (Nottingham Forest).
Kadeem Harris (Cardiff City) wins a free kick in the attacking half.
Substitution, Nottingham Forest. Apostolos Vellios replaces Daniel Pinillos.
Foul by Britt Assombalonga (Nottingham Forest).
Allan McGregor (Cardiff City) wins a free kick in the defensive half.
Attempt blocked. Joe Worrall (Nottingham Forest) right footed shot from the centre of the box is blocked.
Corner,  Nottingham Forest. Conceded by Joe Bennett.
Substitution, Cardiff City. Joe Ralls replaces Anthony Pilkington.
Zach Clough (Nottingham Forest) wins a free kick in the attacking half.
Foul by Aron Gunnarsson (Cardiff City).
Substitution, Nottingham Forest. Zach Clough replaces Ben Brereton.
Substitution, Nottingham Forest. Britt Assombalonga replaces Jamie Ward.
Eric Lichaj (Nottingham Forest) wins a free kick in the defensive half.
Foul by Anthony Pilkington (Cardiff City).
Offside, Nottingham Forest. Ben Osborn tries a through ball, but Ben Brereton is caught offside.
Joe Worrall (Nottingham Forest) wins a free kick in the defensive half.
Nottingham Forest were plunged deeper into relegation trouble as Aron Gunnarsson gave Cardiff victory.