In-form Boro were 2-0 up inside 14 minutes and in total command.
But Stags raised their game after the break with a magnificent fightback that saw Oli Hawkins and Rhys Oates deservedly level the game only to see Boro steal it when O'Toole turned Isaiah Jones' low cross past Nathan Bishop.
Danny Johnson also had a goal ruled out for offside and Oates an effort cleared off the line as Boro struggled to contain a Stags side that had won 10 of their last 11 games.
The Stags side saw two changes from their last game on Boxing Day. Skipper Ollie Clarke and Stephen Quinn were fit again and replaced Farrend Rawson, who was out ill, and Jason Law, who dropped to the bench.
Former Mansfield Town boss Mick Jones dies aged 75
See who you can pick out in our fans gallery from Mansfield Town v Derby County
One more new face in for Mansfield Town as early injuries mount?
Supercomputer predicts the most likely result for Leyton Orient v Mansfield Town, Bradford City v Newport County, Stockport County v Colchester United and every other League Two game
Mansfield Town boss Nigel Clough proud of players and fans as Stags are pipped by Derby County in Carabao Cup classic
Boro made seven changes to their starting XI and gave debuts to new signing, Northern Ireland U21 international Caolan Boyd-Munce, who joined from Birmingham City this week, and Academy product Joe Gibson while William Kokolo made his full debut.
Stags started well and Stirk made a good run into the box on two minutes to get onto a throw and whip a low shot wide of the near post.
But Boro grabbed a fourth minute lead with a stunning goal by Ikpeazu.
Picking up the ball midway in the Mansfield half he fought off challenges from McLaughlin and Hawkins as he powered forward and then from 20 yards smashed a finish into the top left hand corner.
Quinn tried his luck from similar range three minutes later but was too high.
Boyd-Munce then marked his debut with Boro's second goal on 14 minutes.
From a throw on the right, Peltier was able to get to the by-line and stride forward before pulling a low pass back to Boyd-Munce, who stroked home a low finish.
He almost added another five minutes later, but saw his low shot deflect inches wide for a corner from which, when Stags failed to clear, Kokolo whipped a shot over.
Coburn also had a shot deflect inches wide from a scramble on 23 minutes as the visitors looked to further stretch their advantage as heavy rain poured down on the action and the pitch became more sodden.
On 26 minutes McLaughlin's free kick found O'Toole at the far post, but his header dropped wide of the far post.
Stags' first corner on 31 minutes was half-cleared and recycled back out to taker Maris, who cut inside and forced Lumley to dive to his left to keep out a curling finish.
Bamba was booked on 33 minutes for a tackle from behind on Maris.
Boro were then relieved to see no one able to turn home a curling cross from O'Toole from the right by-line that skidded across the face of the goal as the home side enjoyed their best spell of the afternoon so far.
IkPeazu was cautioned for persistent fouling on 37 minutes and a minute later Hewitt's name was added for hauling down Kokolo.
Maris might have pulled one back on 42 minutes when released into space down the centre by Oates, but his finish sailed over.
Boro almost netted a minute later when a low Kokolo cross reached Ikpeazu 10 yards from goal, but Bishop made a superb reaction save to keep out his first time finish.
Maris had a shot blocked as Stags went into the break with a mountain to climb.
Stags began the second half well and three minutes after the restart Oates won a corner which Quinn sent over and Hawkins flicked his header over the bar.
On 53 minutes a cross found Oates at the far post where he stabbed the ball goalwards and Peltier cleared off the line.
Stirk had a shot blocked as Stags kept up the pressure.
On 58 minutes Bowery played a tempting low ball in to Clarke, but the skipper somehow lifted the ball over the bar from inside the six yard box.
Oates again came close on 61 minutes, sending a diving header wide from a McLaughlin cross and a minute later he headed over from close range from Quinn's long cross before Stags made a double change.
Boro threatened for the first time all half on 63 minutes when sub Crooks fired a first time effort into the sidenetting.
But Stags were deservedly back in the contest on 67 minutes.
Quinn hung a fine cross over from the left and Hawkins powered a six yard header past Lumley.
O'Toole and Hawkins were added to the book for fouls soon after.
Howson slid in to cut out a dangerous Oates cross on a 73rd minute Stags break as the home side raised the noise levels.
On 80 minutes Stags thought they had levelled as Lumley let a tame Law shot slip past him and Johnson poked the loose ball home only to be ruled offside.
However Stags were level five minutes from time.
Law cut open the Boro defence with his pass down the centre and Oates raced away, rounded the keeper and slotted home.
Two Boro subs almost conjured up a winner on 87 minutes but Dijksteel somehow lifted a finish over from six yards with only the keeper to beat from Hernandez's cross.
Seven minutes were added in which Hewitt blocked a Jones finish.
But Stags were left heartbroken in the fifth added minute as Jones sent in a low cross after speeding down the right and, with Hernandez behind him, O'Toole slid the ball into his own net.
STAGS: Bishop, McLaughlin (Lapslie 61), Hewitt, Clarke (Johnson 61), Bowery, Maris, Hawkins, Quinn, Oates, Stirk (Law 72), O'Toole. SUBS NOT USED: Stech, Turner, Nartey, Charsley, Burke, Ward.
MIDDLESBROUGH: Lumley, Ikpeazu (Jones 77), Peltier, Wood, Howson, McNair, Bamba, Kokolo (Dijksteel 77), Coburn (Hernandez 62), Gibson (Crooks 58), Boyd-Munce (Tavernier 58). SUBS NOT USED: Daniels, Malley, Sykes.
REFEREE: Keith Stroud.