The visiting Blues started the brighter of the two sides and made their domination count with two goals in the space of three minutes.
The Hammers responded with a goal in the second minute of stoppage time at the end of the half. Vaz Te rose highest inside the area to head a cross from James Tomkins past Boaz Myhill.
However, before the whistle for the break was blown, Birmingham reopened their two-goal winning margin when Chris Burke bounced an effort past Green from outside the area.
West Ham controlled large parts of the second half, but it took until the 69th minute for them draw themselves to within a goal of the Blues. Carlton Cole was the scorer, drilling past Myhill from a narrow angle.
Cole then fired over from 18 yards as the home side searched for the goal that would give them a share of the spoils.
It finally arrived one minute from time when Henri Lansbury's shot was blocked by the hand of Burke. Vaz Te sent the resultant penalty straight down the centre of the goal, with Myhill having dived to his right.
Lansbury had two opportunities to win the match on stoppage, but he failed to make a clean connection on both occasions.
West Ham are now three points behind Reading in second spot.