The Championship match was the Hammers' first since reigning Football Writers Association player of the year Scott Parker joined Tottenham on transfer deadline day, but the Hammers responded with a spirited performance in which debutant Henri Lansbury and goalkeeper Robert Green shone.
After the visitors took the lead through a Luke Varney effort that deflected off Carlton Cole, West Ham equalised a minute later through former Portsmouth midfielder Matthew Taylor's free-kick.
Despite the Hammers dominating first-half proceedings, they had Green to thank for pulling off a number of good saves before Lansbury netted eight minutes into the second period.
Portsmouth equalised in the 60th minute after David Norris' header was adjudged to the cross the line, but then had skipper Liam Lawrence sent off for a second bookable offence.
Steve Cotterill's side visibly struggled with 10 men as a Mark Noble penalty and a superb Cole header secured West Ham a fourth win of the season, although it was tempered slightly by Frederic Piquionne's red card and a Greg Halford penalty in stoppage time.
Hammers boss Sam Allardyce handed a debut to on-loan Arsenal starlet Lansbury and named fellow new boys David Bentley and Sam Baldock on the bench.
The visitors named Benjani Mwaruwari in attack after Dave Kitson fell ill, while Aaron Mokoena replaced Joel Ward in the line-up.
The match kicked off at quiet a tempo and Portsmouth took an eighth-minute lead as Varney's wayward effort from Lawrence's corner deflected in off Cole.
The home faithful responded with a hearty rendition of I'm Forever Blowing Bubbles and were celebrating an equaliser just one minute after falling behind.
After Jason Pearce upended Cole on the edge of the box, Taylor curled in a sumptuous-looking free-kick only for replays to show a slight deflection helped the ball home.
West Ham looked invigorated by the equaliser and dominated the remainder of the first period, with skipper Kevin Nolan, Cole and Joey O'Brien all going close.
Despite the east Londoners' dominance, Allardyce's side almost came a cropper from another corner in the 39th minute.
Green was forced into a superb reaction save to thwart Pearce's goalbound header, before the Hammers defence scrambled the ball out of the ensuing melee.
Minutes later the England goalkeeper was forced into another fantastic save, preventing Erik Huseklepp's low drive with an outstretched leg.
Green's hard work looked to have paid dividends eight minutes into the second half when Lansbury pounced on a loose ball in the box to fire a low shot that just bobbled over the line after taking a deflection off the underside of Pearce.
Portsmouth, though, returned to the attack undeterred and equalised through a Norris header that looked to have crossed the line before Benjani made sure with a header of his own.
The visitors continued to press but were reduced to 10 men in the 67th minute when Lawrence received a second yellow card for a lunge at substitute Bentley.
Six minutes later Lansbury earned the home side a penalty by flicking the ball into Pearce's hand, allowing Noble to step up and strike home from the spot.
West Ham wrapped up the victory in the 76th minute when Taylor fired in a superb ball that Cole managed to head home.
Lansbury almost grabbed a second as the clock wound down, before substitute Piquionne was red-carded against his former club for raising his hands to Greg Halford off the ball deep into stoppage time.
Despite the clock winding down, Portsmouth reduced the deficit to one goal with the last kick of the game as Halford scored after Tal Ben Haim was brought down in the box.