A clever flicked finish from Chicharito on 31 minutes was followed up by a fantastic strike by Ayew moments before half-time, giving the forward three goals in his last two matches.
Palace got a goal back after the interval via the penalty spot through Luka Milivojevic while Joe Hart produced some moments of brilliance in goal, most notably a double stop just before the half-time whistle.
But, despite a gallant effort, West Ham's resolve was broken seven minutes into injury time as Zaha squeezed home with virtually the last kick of the game.
After a tepid start to the game at Selhurst Park the match exploded into life after half an hour. Ayew found Aaron Cresswell in space on the flank, and the defender’s first-time cross eluded the legs of every Palace player.
The ball found Chicharito, who brilliantly finished with the outside of his right foot to put the Irons into the lead.
The finish sprung the home side into action and the Eagles came close to equalising, and would have done, if not for a fantastic double save from Joe Hart.
The England international brilliantly checked his momentum to stop James Tomkins’ headed effort finding the net, before blocking away Zaha’s follow-up effort.
With Hart’s terrific save keeping West Ham in front, Ayew put the Hammers in control just before half-time with a fantastic finish from outside the box. The forward crafted the chance himself, having taken possession on the half-way line, and fired into the top corner from the edge of the area.
Ruben Loftus-Cheek had a chance to half the deficit for Palace in added time but his header went just wide of the post.
It took just five minutes of the second period for Palace to get a goal back however. Angelo Ogbonna brought down Andros Townsend in the box, and Milivojevic tucked away the resulting penalty to cut West Ham’s lead to one.
The Eagles then hit the post through a Yohan Cabaye strike while Jose Fonte, who came off for Declan Rice, saw a header go wide.
Palace continued to threaten and if not for some excellent work by Hart, the home team may have levelled. The shot-stopper palmed away a Zaha effort before also brilliantly saving a Cabaye free-kick.
Captain Noble also put his body on the line with some tremendous blocks in and around the area, stopping Palace from levelling the game. Former Hammer Tomkins then hit the crossbar while Bakary Sako hooked over from two yards.
But, as the game played out to a close, Zaha received the ball inside the box and was able to turn home low effort, breaking West Ham heart's with what was almost the last kick of the match.
West Ham United: Hart; Kouyate, Fonte (76’), Ogbonna; Zabaleta (Antonio 61’), Noble, Fernandes, Cresswell (Masuaku 46’); Ayew, Chicharito, Lanzini
Subs not used: Adrian, Obiang, Arnautovic, Carroll
Goals: Chicharito 31’, Ayew 43’
Crystal Palace: Speroni; Ward (Sako 60’), Tomkins, Dann, Van Aanholt (Fosu-Mensah 11’); Milivojevic, Cabaye, Townsend, Loftus-Cheek, Schlupp; Zaha
Subs not used: Hennessey, Delaney, Kelly, Puncheon, Riedewald
Goals: Milivojevic (p) 50’, Zaha 90+7