The Stags were completely on top in the first half and had an interval 2-0 lead to show for it, thanks to Rhys Oates and Jordan Bowery.
But the Cobblers were not done and after pulling one back on 61 minutes, there were some nervy moments for the Stags as they tired and nerves began to jangle.
Stags were unchanged but the Cobblers made two changes with Jonny Maxted coming in for suspended keeper Liam Roberts and Idris Kanu in for Josh Eppiah, who wasn't fit enough to start.
The game kicked off in bright sunshine and a deafening noise from both sets of supporters.
Stags carved out the first chance on five minutes as Murphy found McLaughlin on the left and his low drilled cross passed inches in front of the outstretched leg of Oates as he slid in to try to turn the ball home.
At the other end on 11 minutes Bishop dived to his right to turn aside a 25-yard shot from Appere.
But the home side swept in front on 13 minutes.
McLaughlin laid the ball to Bowery who sent a cutting pass to Oates, coming into the right hand side of the box, and he buried his low shot under the body of Maxted.
Kanu tried to send Hoskins clear on 19 minutes, but Bishop was alive to it and was quickly out to win the race for the ball.
On 22 minutes the referee produced his first card after McWilliams had brought down Oates.
A cheeky backheel by Hoskins sent Pinnock clear but Stags were rescued by an offside flag.
Instead the home side went 2-0 up on 32 minutes. Longstaff switched the play from right to left with a great ball into space in front of Murphy.
He got to the byline and drilled the ball hard across goal and Bowery popped up to smash it home at the far post.
Three minutes later Oates tried to go it alone on the left but his low shot from distance was wide as Stags went into half-time in the box seat.
Oates almost made it 3-0 just three minutes into the second half as he turned his man neatly with a great first touch from Perch's pass and forced Maxted to make a great save from his powerful finish.
On 50 minutes Maris was booked for his foul on Hoskins, who needed treatment.
On 53 minutes Hoskins was not far away from pulling one back as he tried to curl a 25 yard finish across Bishop from the left but saw his shot bounce wide of the far post.
But Northampton were back in the contest on 61 minutes.
Breaking quickly down the centre, Pinnock led the charge, Perch unable to halt him with a lunge that earned him a booking.
But Appere continued the break and found Koiki on the edge of the box and he tucked away an excellent low finish inside the left post.
There were boos from the home fans as ex-Stags striker Rose came on as a substitute on 66 minutes.
Northampton continued to press and on 79 minutes O'Toole made a superb block to deny Hoskins, Eppiah's close range follow-up deflecting over for a corner from which Horsfall headed wide.
O'Toole made another great interception as Rose sent a low ball in front of goal as Stags hung onto what they had.
STAGS: Bishop, Perch, O'Toole, Hawkins, McLaughlin, Maris, Longstaff (Wallace 60), Quinn (Stirk 77), Murphy (Akins 86), Oates, Bowery. SUBS NOT USED: Stech, Hewitt, Clarke, Lapslie.NORTHAMPTON: Maxted, Sowerby, Guthrie, Horsfall, Hoskins, Pinnock, Koiki, McWilliams, Kanu (Eppiah 56), Mills, Appere (Rose 66). SUBS NOT USED: Woods, Harriman, Pollock, Zimba, Dyche.REFEREE: Anthony Backhouse.ATTENDANCE: 7,469 (1,221 away).