Los Angeles - England needed a last-gasp try to scrape into the knockout rounds of the Los Angeles Sevens on Saturday and deny minnows Spain a place in the last eight.
England had been heading for a humiliating early exit as they trailed New Zealand 21-12 as the buzzer sounded at Carson's Dignity Health Sports Park.
However the English kept their cool and engineered an overlap for 20-year-old Ben Harris, who outpaced the New Zealand cover to score near the posts.
Although the late try could not prevent New Zealand from a 21-17 victory that guaranteed top spot in Pool D, the scoreline vaulted England over Spain into second place on points difference.
Spain, who had earlier stunned England 22-5, just missed out on a place in the Cup knockout rounds, with England's late try against New Zealand proving decisive.
New Zealand, meanwhile, the leaders of this season's World Rugby Sevens Series after wins in Cape Town and Hamilton, enjoyed a smooth start to the competition.
The Kiwis routed Wales 42-7 in their opener before disposing of Spain 21-7 and then defeating England to make it three wins out of three.
The New Zealanders will face France in Sunday's Cup quarter-finals while England will face reigning Olympic and World Sevens champions Fiji.
Fiji, winners of the Sydney Sevens earlier in February, were also impressive on Saturday, defeating South Korea 45-7 before squeezing past France 33-28.
The Fijians locked up first place in Pool A with 38-14 win over Argentina, with Aminiasi Tuimaba outstanding in a two-try performance.
France, who had drawn 26-26 with Argentina in the opening game of Pool D, reached the last eight on points difference after finishing level on six points with the South Americans.
Australia capped an unbeaten run through pool play with a 17-7 victory over the United States. The Group C winners will take on Ireland in the quarter-finals.
The USA, aiming for a hat-trick of victories on home soil, defeated Samoa and Scotland in their first two matches before falling to the Aussies and will take on Group B winners South Africa in the quarter-finals.
The Blitzboks trounced Kenya 31-5 and Canada 33-5 before finishing the night with a 19-19 draw against Ireland.