Portsmouth's FA Cup exploits seemed to have caught up with them as they began sluggishly, and the little early goalmouth action that there was usually involved West Ham striker Bobby Zamora.
He did well to beat Sol Campbell and fire in a cross from the left, but there was no-one on the end of it.
However, minutes later Zamora had only himself to blame when he went round the keeper but made his angle too narrow and fired across the goalmouth.
David Nugent was given a rare start by Portsmouth but did little to grab the attention until Pedro Mendes delightfully backheeled into his path, but his half-volley was just off target and rattled the stanchion behind the goal.
Long-range efforts by Mendes and Papa Bouba Diop gave West Ham keeper Robert Green something to do.
But it was not until the dying seconds of a tepid first half that either goal came under serious threat, with James fumbling Ashton's swerving long-range shot behind for a corner.
Around the hour mark, Zamora went off and teenager Freddie Sears came on to try and make a difference for West Ham, but the difference that was made was not the kind they would have wanted.
Kranjcar, who had already given West Ham warning of his ability before he put Portsmouth ahead, took his time before finding the net with a neat turn and low shot into the bottom right-hand corner.
Carlton Cole came on to try and add some physical presence and height up front for the home side but Campbell and Sylvain Distin defended stoutly in front of James's goal, and having gone in front, Portsmouth's lead was never seriously threatened.
West Ham manager Alan Curbishley:
"We thought this was winnable tonight but Portsmouth did all the threatening in the second half.
"We are stuck in 10th but we won't finish there if we don't win any more games and there are five left in which we must do better than tonight."
Portsmouth manager Harry Redknapp:
"Niko's an outstanding footballer, real class. You all saw the goals he scored against England and Scotland for Croatia.
"I took West Ham to fifth spot once when I was here and it would be nice to do the same with Portsmouth.
"We've come a long way in the last few years. I've come back three times here and won now and the buzz is still as great."
Bookmark with:
What are these?