Carlton Cole was on hand to convert from close range from Matt Jarvis' excellent pass, before James Tomkins was sent off in the second half.
But Mark Noble sealed the win in stoppage time, and with Andy Carroll making a first appearance of the season as a substitute this was a good day for Allardyce with co-owners David Gold and David Sullivan in attendance.
Fraizer Campbell, Craig Noone and Mark Hudson failed to convert the best chances for the hosts, who replace West Ham in the bottom three, and this will have outlined to Ole Gunnar Solskjaer the task he will face in keeping the Bluebirds up.
Allardyce's position has been under severe scrutiny in the wake of heavy cup defeats against Nottingham Forest and Manchester City, and the Hammers lying 19th the table.
The mood at Cardiff may have been lifted by Solskjaer's arrival but with the Bluebirds a point and a place above the drop zone it was little surprise there was such a nervy start.
Cardiff survived an early scare when West Ham hit the post inside three minutes. Stewart Downing's cross missed everyone and cannoned out of the far post, where Tomkins' follow-up was smothered by David Marshall.
Tomkins' return from injury had provided a timely boost for Allardyce who is without the likes of Winston Reid and James Collins.
But he lost another defender in the eighth minute when Guy Demel went down. Campbell had just failed to connect with Peter Odemwingie's cross and when the ball was quickly put back into the box the striker collided with Demel and Roger Johnson.
Johnson's elbow appeared to strike Demel and the Ivorian required lengthy treatment before being stretchered off with a suspected broken elbow and facial injuries.
The long disruption ensured there was little flow on the resumption until George McCartney, on for Demel, blocked superbly from Craig Noone.
Cardiff looked the more likely to score and they thought they had in the 32nd minute.
Kim Bo-kyung's shot deflected off Johnson, struck the bar and appeared to cross the line as it came down. No goal was given and Campbell gave away a foul as he bundled Adrian and the ball over the line.
But replays showed the Goal Decision System had been correct, with the ball landing on the line.
Noone was again denied, this time by Adrian, before the visitors opened the scoring.
Matt Taylor picked out Jarvis, and the winger's weighted pass gave Cole an easy tap in.
That prompted Solskjaer to hand fit-again Craig Bellamy a first appearance since November 9 in place of Odemwingie.
It nearly paid immediate dividends as the veteran's free-kick found an unmarked Hudson, who headed over.
McCartney survived penalty shouts for handball and what looked like a clear push on Campbell, before the striker worked Adrian from Bellamy's pull-back.
It was all Cardiff and West Ham were pegged further back when Tomkins saw red as he picked up a second booking for a foul on Campbell after earlier being cautioned needlessly for dissent.
But West Ham survived and Noble finished a sweeping break from Carroll's pass to secure the spoils.