In the opening exchanges, Matthew Etherington was denied by Paul Gerrard while Andy Reid blazed over after Steve Bywater could only parry a cross.
Malky Mackay and Nigel Reo-Coker received early bookings for fouls on Gareth Taylor and Paul Evans.
Gerrard parried a Reo-Coker shot over the bar after Teddy Sheringham set him up while Etherington had a well-struck free kick saved.
Marlon Harewood clipped a shot just over on the run seconds before the break.
Shortly after the restart, Carl Fletcher became West Ham's third booking for a foul on Eoin Jess.
West Ham got their noses in front when Forest old boy Harewood side footed home a simple chance after good work by Etherington, who had robbed James Perch to race down the left hand side and cut the ball back to him.
Steve Lomas then came on for Luke Chadwick, with Nigel Reo-Coker going to the right of midfield.
Paul Evans put Forest back into the game with a low hard strike from 25 yards after riding a challenge from Steve Lomas - to the disappointment of West Ham's 1,344 travelling fans.
Substitute Eugen Bopp then caressed a side foot shot just over Bywater's bar and fellow substitute Marlon King shot just wide.
But, with seconds remaining, King - subject of jeers from his own fans after he recently declared he wanted to leave, smashed home a curling shot past the despairing dive of Steve Bywater.
There was a moving tribute to Brian Clough beforehand, with the trophies that he won on display, many of the fans wearing green sweatshirts - Cloughie's trademark - and his favourites songs, including 'My Way', being played ahead of kick-off.
All of the players wore black arm bands and a minute's silence was impeccably observed.
Steve Bywater, Carl Fletcher, Calum Davenport, Chris Powell, Luke Chadwick and Teddy Sheringham were all recalled to the starting line-up after missing out against Notts. County in the Carling Cup.
TEAM: Bywater, Repka, Mackay, Davenport, Powell, Chadwick [Lomas], Reo-Coker, Fletcher, Etherington, Sheringham, Harewood.
Subs unused: Walker, Mullins, Rebrov, Zamora.
Attendance: 25,615