United trailed for long periods in a match they needed to draw to ensure their progress from Group B and had looked like suffering their first European defeat at home since February 2005 during a below-par display.
Sir Alex Ferguson had opted to shuffle his pack with Rio Ferdinand, Nemanja Vidic and Ryan Giggs missing through injury and Wayne Rooney on the bench following the arrival of his first child earlier in the day.
That saw the likes of Federico Macheda, Wes Brown, Fabio, Michael Owen and Darren Fletcher come into the side and the changes seemed to have an effect as United were disjointed early on.
Fletcher and Macheda had come close to opening the scoring inside the first 20 minutes before CSKA Moscow took a shock lead on 25 minutes.
Alan Dzagoyev played a neat one-two to open up the defence before lashing a rising left-foot shot past Edwin van der Sar from an acute angle.
United were back on level terms four minutes later when Nani inadvertently turned Valencia's hopeful cross into the path of Owen, who produced a composed finish from inside the six-yard box.
However, Old Trafford fell into a hushed silence virtually from the restart when Milos Krasic raced on to Dzagoyev's chest down and rounded van der Sar before tucking away their second goal of the night.
Shock turned into amazement two minutes into the second half when more lacklustre defending allowed Vassily Berezutsky to sneak in at the back post and squeeze home a header from what should have been a harmless free-kick.
Ferguson's response was to send on Rooney and Patrice Evra but the veteran manager and his players were left seething on the hour-mark when Fletcher was clearly tripped in the box but the referee waved away their penalty appeals.
To rub salt into the wounds the Scotland midfielder was then booked for diving by a Portuguese referee who had a poor night.
United then found visiting keeper Igor Akinfeev - a reported transfer target - in their way as he turned away a 30-yard free-kick from Paul Scholes and then produced two stunning double saves.
First he repelled a downward header from Owen before blocking Rooney's close-range follow up with an outstretched leg and then, after Macheda had rattled the upright with an eight-yard header, Rooney was again denied by the acrobatic keeper.
However, United managed to reduce the deficit on 84 minutes when Scholes was left unmarked to head home a free-kick from close range.
And the fightback was completed in the final minute when the unlucky Georgy Shennikov deflected a shot from Valencia which was heading well wide into his own net.