Third Division Mansfield looked to have forced extra time after Sunderland substitute Kevin Kyle deflected a Liam Lawrence cross into his own net less than a minute from time.
But then, four minutes into injury time, Kyle made amends, ramming home one of several dangerous crosses from Matt Piper to end Sunderland's 16-game losing streak.
It was their first shot on target all night, although the unlucky Marcus Stewart saw a glancing header bounce to safety off the inside of the post 18 minutes from time.
McCarthy had rung the changes after another defeat at the weekend with only outstanding keeper Mart Poom, Phil Babb and Kevin Kilbane surviving the axe.
One of the recalled players should have made his mark after just 17 seconds.
Quick passing between Kilbane and Stewart released Piper but the winger, who had a successful loan spell at Mansfield 18 months earlier, drilled his low shot narrowly wide.
In the tenth minute Stewart, looking for his first goal since December, curled a shot narrowly wide after a powerful surge from Tore Andre Flo.
Five minutes later the home side finally created a chance. Poom, who had already twice raced out of his area to head clear, dived full length to tip Wayne Corden's 25-yard curling free kick around the woodwork.
The save proved vital just three minutes later when the visitors were gifted an 18th minute lead, Stags defender Dave Artell flicking an inswinging corner into his own net.
Another breathtaking save by Poom, palming away Lee Williamson's close range shot, preserved the lead.
Then Junior Mendes spooned his 20-yard finish over the bar after a lucky rebound off Babb.
Mendes again fluffed his finish on the stroke of half time racing clear from the halfway line before shooting tamely straight at the keeper.
Mansfield: Pilkington, Hassell, Dimech, Artell, Clarke, Lawrence, Curtis, Williamson, Corden, Christie, Mendes. Subs: Andy White, Day, Disley, Jason White, MacKenzie.
Sunderland: Poom, Williams, Clark, Babb, Gray, Piper, Thornton, Whitley, Kilbane, Flo, Stewart. Subs: Ingham, Thirlwell, Wright, Kyle, Oster.
Referee: Paul Taylor (Hertfordshire).
Attendance: 5,665