Pompey keeper Jamie Ashdown set a new club record for post-war league minutes without conceding a goal when the game reached the 35-minute mark.
However, Albert Adomah's strike five minutes later and a Greg Halford own goal midway through the second half were enough for City to record a quartet of successive league wins for the first time since February 2009.
Dave Kitson pulled a goal back in injury time but Portsmouth's club record-equalling run of six consecutive victories and clean sheets had already come to an end.
Steven Caulker failed to recover from the hip problem that forced him off during the first half against Coventry on Saturday.
Damion Stewart, who replaced the on-loan Tottenham defender at the Ricoh Arena, was the only change to the Bristol City starting line up.
Portsmouth were unchanged from their win over Sheffield United at the weekend.
Nicky Maynard came close to his fourth goal in as many matches when he volleyed wide from a corner after seven minutes.
Portsmouth threatened when former Pompey keeper David James spilled Hayden Mullins' shot but the ex-England international recovered to collect the loose ball ahead of the onrushing David Nugent.
David Clarkson thought he had put City ahead on the half-hour but his close-range finish was ruled out for offside.
Ashdown then surpassed Peter Mellor's club record without conceding a goal set during the 1978-79 season but he was beaten soon afterwards.
Adomah embarked on a solo run and, after a neat one-two with Clarkson, steered the ball past Ashdown from 10 yards out. It was the first goal Ashdown had conceded in 636 minutes of Championship football.
Joel Ward went close to an equalising goal either side of half-time. He first lifted a shot just over James, who was out of his goal, before almost catching out his old team-mate with an inventive effort from by the touchline.
Portsmouth appealed for a penalty when Stewart kicked the ball against his own arm in the 51st minute but the appeals were waved away.
Ward went close again, this time with a header, before Pompey fell further behind when Halford turned Maynard's cross into his own net.
It needed a superb save from James to keep out Kitson's thumping, angled drive after 75 minutes.
But the former Reading and Stoke striker got on the scoresheet in the third minute of injury time when he converted Carl Dickinson's left-wing cross from inside the six-yard box.