Four goals from Aiyegbeni Yakubu made sure Portsmouth's season ended on a high note, despite the ongoing doubts over boss Harry Redknapp's future.
Yakubu struck on four minutes, then hit a penalty to put Pompey in control.
A long-range strike from Boudewijn Zenden gave Boro hope but Yakubu made it three on 31 minutes, slotting home after Ugo Ehiogu mis-hit a clearance.
A late Teddy Sheringham goal - in his final game for the club - was followed by Yakubu's smart finish on 83 minutes.
Portsmouth began the match looking as though they would treat their shirt-sleeved fans to a cricket score.
Yakubu was the man behind Middlesbrough's downfall, with the Nigerian needing just over half an hour to complete his hat-trick.
His first was confident strike from just inside the box after Eyal Berkovic's astute pass inside Danny Mills.
4 Mins: Yakubu fires Pompey ahead
14 mins: Yakubu penalty doubles lead
27 mins: Zenden belter gives Boro hope
31 mins: Yakubu completes hat-trick
80 mins: Sheringham nets for Pompey
83 mins: Yakubu scores his fourth
Boro could have equalised soon afterwards, as Gaizka Mendieta's cross caused confusion between Petri Pasenen and Shaka Hislop, although the ball was cleared.
On 14 minutes, however, Yakubu made it two from the spot, picking himself up to score after being fouled inside the box by Mills.
But the party mood in the home crowd was quelled on 27 minutes as Zenden halved the deficit with a quality strike from distance which flew past Hislop.
Yet Pompey responded well, and their two-goal lead was restored just after the half-hour as Yakubu completed his quickfire treble after a blunder by Ehiogu.
The former England defender hashed a clearance and knocked the ball against the striker who gleefully slotted home from close-range.
Franck Queudrue then missed a difficult chance for Boro when the ball came at him quickly, and Joseph-Desire Job blasted wide just before half-time.
Portsmouth continued to press after the interval, with Lomana LuaLua seeing a six-yard effort saved by Schwarzer, and Alexei Smertin having a shot blocked by Queudrue.
Unsurprisingly, the pace slowed during the second period.
Mendieta and Queudrue had long shots for the visitors which went wide, but as the match trundled towards a dull finish, Portsmouth netted two late goals.
Sheringham finished his Pompey career on a high, netting from six yards after good work by Matthew Taylor.
Then Yakubu completed a brilliant afternoon's work with a smart right-foot finish from 18 yards.
It made it 11 goals in the past 10 games from the Nigerian and sent the majority of the crowd home in high spirits.
Portsmouth: Hislop, Pasanen (Curtis 45), De Zeeuw, Stefanovic, Taylor, Stone, Berkovic, Smertin, Quashie (Hughes 81), LuaLua (Sheringham 67), Yakubu.
Subs not used: Wapenaar, Mornar.
Middlesbrough: Schwarzer, Mills, Queudrue, Ehiogu, Zenden, Mendieta, Boateng, Greening, Downing (Morrison 62), Nemeth (Ricketts 62), Job.
Subs not used: Nash, Wilson, Bates.
Referee: M Halsey (Lancashire).