Fulham lost a game they should have won twice over.
If three points prove a major difference at the end of the season - this one will surely come back to haunt them.
They bossed the first half, but scored only once through Ross McCormack's delicious lob on three minutes, and then found themselves on the back foot.
When Marlon Pack rifled home in the second half, they still had chances to win it. Sub Cauley Woodrow was denied at close range, as was McCormack, and towards the end there was the mother of all scrambles with City finally hacking clear.
But a killer free-kick from Lee Tomlin in the 90th minute landed Fulham right back in the relegation mess.
Home seats tipped up as Whites fans exited and booed all the way to the final whistle.
The signs were there after 50 seconds. Joe Bryan played through on the left with the defence asleep apart from Lonergan who was down quickly to block with his legs.
No sooner had they survived that scare, McCormack lobbed the goal of his life.
He took a long ball from Michael Madl down the right in stride, and a deft touch on the angle looped for an age over Richard O'Donnell but eventually plopped neatly into the far corner of the net.
The City keeper was caught out again on 20 minutes by a long-ranger from McCormack which he dropped and Dembele got to first, only to find the assistant's flag raised.
A long throw from the right saw an inadvertent Fulham back header inch wide of the far post to make home hearts flutter.
As in the first half, straight from the start City came out of the traps and Tomlin made Lonergan dive full length left to tip a shot around the left-hand post.
Dembele should have made it 2-0 on 54 minutes when through, but that touch too many as he hurtled towards goal allowed O'Donnell time to block.
The action swung back the other way seconds later and a brave tackle from Ryan Fredericks was the only thing stopping a goalbound shot from sub Peter Odemwingie.
There was nothing Whites could do after Luke Garbutt gave away the ball in Fulham's final third on 69 minutes.
The intended pass was picked off by Marlon Pack and evaded one tackle before firing right-footed low and true beyond Lonergan's right to set off red smoke flares in the away end.
The light went out under Fulham when Tomlin netted the winner. Hopefully, the war boss Slavisa Jokanovic referred to still has some winning battles to go.