The hosts had dominated most of the contest and yet were trailing at the break to goals from Callum Lang and Will Keane.
But George Hirst struck twice in quick succession in the second half and the Latics tried to hang on for the point that would have guaranteed them a spot in the Championship.
They could not see it out to the end, however, as O’Brien found the bottom corner to earn a deserved win for the in-form Blues.
Danny Cowley named an unchanged side following Pompey’s comfortable win over Gillingham at the weekend.
Their opponents also declined to make any alterations, meaning that Jack Whatmough and Tom Naylor both featured against their former club.
The home side soon began to dominate the contest and applied plenty of pressure, without being able to test Ben Amos between the sticks.
A couple of dangerous deliveries from Hayden Carter and Michael Jacobs had to be hacked to safety by the Latics.
Jacobs then sent a corner into the box, where Sean Raggett could only nod wide after rising in a crowded box.
They almost broke the deadlock when Jacobs stole possession and found Hirst, who fired a rocket narrowly past the post.
But, totally against the run of play, it was Wigan who went ahead on 38 minutes after Jordan Cousins had intercepted the ball.
He found Tom Pearce, who swung in a fine cross that Lang dived on to head past Gavin Bazunu from close range.
It was harsh on Pompey and they should have levelled in stoppage-time, as Connor Ogilvie side-footed wide after being found in the box by Hirst.
And they were made to pay for their profligacy when Pearce sent in another low cross that was turned home by Keane.
Wigan Athletic 2
The hosts went back on the attack when the action restarted and Tendayi Darikwa did well to stop Ronan Curtis getting on the end of a Marcus Harness cross.
But the Latics soon had a chance to extend their advantage, with Gavin Bazunu getting down to his left to keep out a firm Naylor header.
Instead, however, Pompey incredibly found themselves level with two goals in as many minutes just past the hour mark.
The first was down to some superb work from Harness, who nutmegged Naylor and refused to be outmuscled before sending in a low centre for HIRST to arrow into the net.
Amos was booked for refusing to return the ball for the kick-off, while Curtis also got punished for trying to wrench it from his arms.
And it was HIRST who scored again just a few moments later, bending the ball home from the edge of the box after Darikwa had made a mess of dealing with a blocked Curtis shot.
The Blues were rampant by this point and Amos did well to prevent Harness from firing them ahead from an acute angle.
And the keeper then dealt nervously with a speculative – and swerving – 25-yard strike from Louis Thompson.
Cowley soon freshened up his attacking options, with O’Brien coming off the bench to replace Jacobs.
The visitors appeared happy with a point and were doing their best to waste time over every set-piece.
But the Blues continued to put pressure on the nervy visitors and deservedly went ahead on 87 minutes.
A Joe Morrell free-kick found Hirst in space and after his shot was saved by Amos, Wigan could not get the ball clear.
O’BRIEN picked it up just inside the box and angled a low finish right into the bottom corner, with Fratton Park erupting.
Wigan suddenly needed to pick up the pace again, but the Blues defended resolutely to claim all three points.
Pompey (4-2-3-1): Bazunu; Carter, Raggett, Robertson (c), Ogilvie; Morrell, Thompson (Tunnicliffe 86); Harness (Romeo 90), Jacobs (O’Brien 77), Curtis; Hirst
Goals: Hirst 62, 64, O’Brien 87
Subs not used: Webber, Williams, Mingi, Walker
Wigan (3-4-1-2): Amos; Kerr, Whatmough, Bennett (Edwards 80); Darikwa (c), Naylor, Cousins (Humphrys 90), Pearce (Massey 72); Power; Keane, Lang
Goals: Lang 38, Keane 45+3
Booked: Darikwa, Amos
Subs not used: Jones, Watts, Shinnie, Aasgaard
Referee: Craig Hicks
Attendance: 14,637 (792 away fans)