Lee Bowyer scored his first Ipswich goal a minute from time to inflict a first defeat in seven matches on his former club West Ham.
The midfielder tapped in after Keith Andrews' header from Jimmy Bullard's corner had hit the post.
Bowyer had come close to opening the scoring when his 12-yard effort hit a post in the first half.
The closest West Ham came was when Kevin Nolan's close-range header was cleared by Aaron Cresswell.
The goal from Bowyer, who had two spells at Upton Park, earned Ipswich a second win in three games to hand manager Paul Jewell, who turns 47 on Wednesday, an early birthday present.
It ended the Hammers' seven-game unbeaten run in the Championship as the hosts, who have made their best start to a league season in 28 years, squandered the chance to move top of the table.
Ipswich made a bright start and Michael Chopra's close-range effort was saved by Robert Green. Bowyer's shot then hit an upright before West Ham had a chance as Henri Lansbury fired a 30-yard shot off-target.
That seemed to spark Sam Allardyce's side into life but Abdoulaye Faye could not keep his header down from David Bentley's corner - and at the other end Green was forced into another save when Grant Leadbitter shot from 18 yards.
West Ham made a better start to the second half and, within five minutes, Carlton Cole tested Ipswich goalkeeper David Stockdale with an 18-yard strike.
Another long-range Leadbitter strike was easily dealt with by Green before Cresswell's excellent block kept out Nolan's header.
With eight minutes left, Green was at full stretch to tip Cresswell's 30-yard free-kick over the crossbar. Just as the game was seemingly heading for a goalless draw, Bowyer popped up to stun the Hammers.
Stockdale was called upon to save from Jack Collison in injury time but Town secured a third successive clean sheet, the first time they have achieved that feat since March 2005.