The Stags were leading at half-time through a Mike Gosney goal. But a double substitution by home boss Eddie Stein changed the face of the Spencer Stadium encounter in Oxfordshire.
Two goals in five minutes from substitutes Chris Lait and Nabil Shariff turned what looked like a rare away win into a confidence sapping defeat for Riley and co.
It was hard to take for the travelling faithful who had seen their side boss the game for the first hour and lead with a fine strike from Gosney midway the first half from an inch perfect pass from Dave Allen.
Richard Gillespie could and should have rescued a point when he was clear through with just home keeper Lewis Kidd to beat, but he skied his shot.
Riley was naturally disappointed and frustrated.
“We should have done better having controlled the game for an hour,” he said. “Again I can’t fault the commitment but the mental toughness is lacking.
“We gave away two careless goals – the first was a free-kick we need not have given away, as it put us under pressure, and we were not organised in a mad five minutes.”
“Gillespie would have finished that chance on our pitch but the ball bobbled in front of him, but we created chances and didn’t put them away.
“The delivery is there, now we have to put the chances away.”
Earlier James Coutts and Gillespie had both gone close for Totton while at the other end the strikeforce of Ade Talabi and Kynan Isaac were busy in patches but with Gareth Barfoot saving everything it looked good.
Ten minutes before the b r e a k Gosney’s c o r n e r c a n n o n e d into the net off a defender, but it had already gone out of play, and just before the break Baily Cargill ventured upfield and his half volley went just wide.
Totton continued to look busy and Dave Allen and Gillespie tested Kidd.
But on the hour Lait was introduced and the game changed as Totton dropped deeper.
Lait ghosted in to flick home the equaliser and Shariff netted the winner with his first touch five minutes later to stun the visitors.