Spain, ranked 11th, equalised four minutes before halftime at a penalty corner when Alert Beltran reacted sharpest to jab a rebound in after New Zealand goalkeeper Devon Manchester blocked the initial shot.
Inside a minute of the third quarter starting, Spain were in front when Shea McAleese lost the ball and Spanish attacker Gabriel Dabanch Nasrala, with a deft deflection to a long range drive, beat Manchester.
New Zealand's penalty corner woes in the tournament continued when first Kane Russell had a shot blocked by a fast-breaking defender; then Nick Haig drove his shot, which was flying well wide of goal, into the back of Child's shoulder.
Hugo Inglis, Stephen Jenness and Child all toiled hard up front but when New Zealand withdrew Manchester to play an extra attacking player in the last four minutes it immediately went wrong.
Spain broke out of defence for Andres Mir Bel to poke the ball into an empty net.
Spain, who were ranked sixth best team at the tournament, therefore bettered that ranking and have a terrific chance of progressing to Rio.
New Zealand, whose ranking had them fourth best team in the tournament, still have their fate in their own hands, but face a daunting prospect in Taranaki against the world champions.