The Wales striker scored with virtually his first touch as Burnley came from behind to end the Hammers' seven-game unbeaten run.
All appeared to be going to plan for Sam Allardyce's promotion favourites when Kevin Nolan fired them ahead just after half-time, especially with leaders Southampton losing at lowly Doncaster.
But things are never simple at Upton Park and Chris McCann grabbed a leveller against the run of play before Vokes popped up with the winner.
The Hammers had dominated the first half but could not make the breakthrough.
The first real chance fell to Matt Taylor in the 27th minute, the midfielder heading Julien Faubert's cross over the top.
Moments later Nolan fluffed the best chance of the first half.
Jack Collison took advantage of a slip in the Burnley defence to play in Carlton Cole and the striker squared for Nolan, right in front of goal, eight yards out.
The midfielder got his left foot to the ball but his effort rolled just the wrong side of the post.
Burnley's first shot came 10 minutes before the interval, Keith Treacy's long-range effort not troubling Robert Green as it fizzed wide.
West Ham's pressure finally told seven minutes after the interval, and came from a long clearance from keeper Green.
Cole flicked the ball on and Nolan coolly lifted his finish over the advancing Lee Grant and into an empty net.
But far from the goal signalling the opening of the floodgates, Upton Park was stunned five minutes later when Burnley grabbed an equaliser.
Former Hammers winger Junior Stanislas, sold by Allardyce in the summer, swung in a cross from the right and McCann was on hand to bury his header past Green.
Shell-shocked West Ham went straight back on the attack and Frederic Piquionne headed Faubert's cross straight at Grant before a shot from Collison was blocked in front of goal.
But Burnley remained dangerous on the break and Ross Wallace had Green scrambling across his goal with an effort which rolled just wide.
The warning was not heeded by the West Ham defence and in the 74th minute Burnley took a surprise lead, Wallace swinging in a corner and Vokes, who had only been on the pitch a couple of minutes, climbing highest to nod past Green.
Cole shaved a post as West Ham attempted to haul themselves level but the Clarets held on for a third straight win.