He collected the ball in his own half and raced to the edge of the area before firing an unstoppable shot past England keeper David James.
That took the Wanderers six points clear of the Hammers with a better goal difference and only four games to play.
And although the Hammers had the better of the second half they never really threatened and then had defender Ian Pearce sent off by referee Uriah Rennie for a foul on Pierre-Yves Andre followed by a push on Gudni Bergsson.
By that time the game had developed into a bad-tempered affair with seven bookings and a couple of minor scuffles.
Even at the final whistle players had to be separated as Wanderers relief and Hammers frustration boiled over.
Despite the importance of the game and the tension that was associated with it, both sides initially were surprisingly happy to play some open football.
That allowed players like Okocha and Joe Cole to start pulling at the strings and had Henrik Pedersen and Hammers striker Jermain Defoe been more forceful with their shooting then there could have been earlier goals.
Instead Okocha decided to take it on himself to attack the goal and he came within an ace of scoring only to see his shot cannon off the foot of the post with James beaten.
Earlier Okocha had fired an effort over the bar while Pedersen missed from a good position just outside the six-yard box.
West Ham too had chances of making the first important strike but Frederic Kanoute fired one chance wide before producing another tame shot that was easily dealt with.
In fact it was from a West Ham attack that Wanderers took the lead in the 38th minute.
Bergsson blocked a Hammers shot on the edge of Wanderers area, the ball going out to Ivan Campo, who fed Okocha inside the player's own half.
Setting off on a run straight towards the Hammers penalty area, he shrugged off the challenge of Cole before firing a 25-yard shot into the top corner.
James had no chance with the shot but he produced two vital saves within a minute to save his side falling further behind.
First he dived at the feet of Okocha to smother the ball before chipping a terrific shot from Bernard Mendy over the bar.
Yet Wanderers dominance in the first half looked to have been wasted as they surrendered territorial advantage to the Hammers.
That allowed West Ham to push forward but fortunately for the home side they had a formidable defensive trio in central defenders Florent Laville and Bergsson and Keeper Jussi Jaaskelainen.
Defoe and Cole both had chances to put the scores level but were guilty of wasting clear-cut openings.
Inevitably West Ham's frustrations boiled over with bookings for Defoe, Steve Lomas, Glen Johnson and Cole while home players Laville, Campo and Mendy also followed them into the book.
And to make matters worse for West Ham, Pearce was red carded for a moment of madness in the 90th minute after fouling Andre and pushing Bergsson.