Defeat against the Robins would have effectively relegated the Chairboys and they were staring into the abyss after Tyreeq Bakinson's stunner left them trailing at half-time.
Uche Ikpeazu's header levelled matters before Akinfenwa kept his cool at the death to score his first goal in English football's second tier to move his side six points off fourth-from-bottom Derby.
Bristol City's Han-Noah Massengo had the first half-chance after six minutes when he brought down a long ball before prodding a shot just wide of the near post.
McCleary then got in behind down the left from Ikpeazu's flick-on before his improvised lob from a difficult angle dropped out of the sky and wide, as the Chairboys began to make most of the running.
However, they could do nothing about Bakinson opening the scoring in the 28th minute when he brilliantly swept Adam Nagy's pass into the top corner from long range.
The hosts almost swiftly drew level when Muskwe swept Jason McCarthy's cross into the side netting, but they still trailed at the break after being unable to forge any more openings.
Nakhi Wells had a quiet first half, but he had a sight of goal three minutes after the restart, following a one-two with Famara Diedhiou, only to blaze his shot well over the bar.
Wycombe continued to plug away in attack without success and turned to youngster Anis Mehmeti from the bench as they searched for an equaliser in the last half-hour.
The change paid off in the 65th minute, as Mehmeti played in a peach of a cross from the right that was powered into the net at the back post by the head of Ikpeazu.
The big striker almost completed the turnaround three minutes later after Diedhiou's defensive header dropped his way, but Bentley was able to hold on to his overhead kick.
Two substitutes combined to almost put Bristol City ahead again, with Saikou Janneh playing in Antoine Semenyo and Wycombe goalkeeper David Stockdale saving his shot at his near post.
Akinfenwa had a curling effort clawed around the post by Bentley in the 88th minute, but he was given one more chance to win it deep into added time.
Incredibly it came from a shot from Stockdale, who had remained up from a corner, that was handled by Kasey Palmer and Akinfenwa sent Bentley the wrong way to spark wild celebrations.