The Stags, 78 places below Premier League Boro's all-stars, forgot their Football League relegation fears to worry Gareth Southgate's side.
Micky Boulding hit the bar and might have had a hat-trick as the home side matched Boro throughout 90 entertaining minutes.
The Premier League side looked on course for a routine victory when Dong-Gook Lee gave them an early lead, but the crucial second goal did not come until three minutes from time.
Boro's only comfort from a poor display will be that the last time the Stags lost to a top-flight team in the fourth round, that side went on to win the FA Cup - Wimbledon in 1988.
The Stags tore into Boro from the kick-off and Robert Huth had to dive to head away Stephen Dawson's cross, before Matt Hamshaw drove well wide in the opening 90 seconds.
The Teessiders struggled to impose their class on the tie before grabbing an undeserved 17th-minute lead.
Stags keeper Carl Muggleton failed to get any length on his clearing punch and, when David Wheater's first shot was blocked, the ball ran kindly for Lee to knock in from six yards.
The League Two underdogs continued to take the game to their illustrious hosts however, and Mark Schwarzer had to race out of his area to clear from the onrushing Boulding.
At the other end Julio Arca poked wide at the near post after a fine run by Jeremie Aliadiere and then the Argentinian robbed Lee Bell before seeing his powerful goalbound shot blocked by Jake Buxton.
Boro defender Huth was fortunate to escape with just a yellow card midway through the half for a high foot that went into the midriff of Boulding.
And they were given a double let-off in the 35th minute. First Boulding's long raking drive was tipped onto the bar by the flying Schwarzer and then, from the resulting corner, the striker's header was again clawed away from the top of the net by the keeper.
The game was held up when fans protesting against Mansfield owner Keith Haslam's delay over selling the club launched several footballs onto the pitch, bearing the slogans 'Mansfield For Sale' and 'Haslam Out'.
Boro should have put the tie beyond the home side when Aliadiere again broke clear inside the area but, with the goal gaping, Lee headed wide.
The miss almost proved vital in first-half stoppage time when a bobble caught out Schwarzer, but his miskick fell kindly for the visitors. Then, with the Boro defence still hesitant, Simon Brown failed to make the most of a loose clearance and the keeper saved comfortably.
All Mansfield's chances were falling to their leading scorer Boulding, but seven minutes into the second half he again failed to find a leveller, this time touching Hamshaw's fine cross narrowly wide. The 15-goal forward then knocked another Hamshaw cross wide.
The Stags had dominated the start of the second period just as they did the first, but their pressure could not be turned into a goal.
And 19 minutes from time Arca should have ended their hopes, but, after bursting clear from a Mansfield corner, his pass for the unmarked substitute Stewart Downing was over-hit.
However, Mansfield's dreams of an upset finally ended, three minutes from time, when Boro broke away from a home free-kick. Fabio Rochemback picked out substitute George Boateng in space. His lobbed cross-shot was going in, but Stags defender Buxton inadvertently deflected it over the line.