Ben May put the Lions ahead in the 25th minute and Paul Robinson headed in Don Hutchinson's corner to put them 2-0 up.
Simon Brown pulled Mansfield back into contention before Richard Barker made it 2-2 when he turned in Brown's cross.
But Livermore sealed the win as his shot got a good bounce to defy Kevin Pressman and put Millwall through.
Millwall manager Colin Lee:
"A win is a win is a win and it's nice to progress.
"At 2-0 you never think it's game over because that's the wrong attitude to take and Mansfield really came back to bite us.
"And we know if we perform like that in the Championship then we're not going to be winning any games.
"But getting to the last 16 of the competition was a great incentive for us and if we get a big team in the next round then all well and good."
Mansfield: Pressman, Jelleyman, Baptiste, Hjelde, Buxton, Rundle, D'Laryea, Coke, Uhlenbeek, Barker, Brown. Subs Not Used: Dawson, Birchall, White, Jacobs, Littlejohn.
Booked: Barker.
Goals: Brown 67, Barker 68.
Millwall: Marshall, Craig, Paul Robinson, Lawrence, Elliott (Cogan 73), Livermore, Hutchison (Morris 73), Dunne, Hayles (Braniff 90), Asaba, May. Subs Not Used: Igoe, Masterson.
Booked: Dunne, May, Marshall.
Goals: May 25, Paul Robinson 61, Livermore 90.
Att: 4,133
Ref: M Riley (W Yorkshire).