- Hinata Miyazawa (12', 40')
- Riko Ueki (29')
- Mina Tanaka (82')
Striker Riko Ueki also scored on the break as Japan cut through Spain's high press three times in the first half before substitute Mina Tanaka added the fourth with another quality strike eight minutes from time.
Monday's game was the first time Spain have conceded four goals in a single match for 11 years.
Japan, winners of the 2011 World Cup and runners-up in 2015, will remain in New Zealand's capital to play Norway in the round of 16 on Saturday, while Spain will move north to Auckland to face Switzerland earlier on the same day.
Both teams had already qualified for the knockout stage after convincing wins in their first two group matches and Japan coach Futoshi Ikeda made five changes to his side for the clash at Wellington Regional Stadium.
Spain took the initiative from the start and Japan's opener in the 12th minute was very much against the run of play.
Jun Endo on the left wing curled a pass behind the Spanish defence and Miyazawa raced in to coolly slide it into the net with her left foot.
It was Miyazawa's third goal of the tournament and the first Spain had conceded in their three games in New Zealand.
Spain continued to dominate possession and territory but Japan hit them on the break again in the 29th minute and Ueki, released by Miyazawa, fired a shot at goal that took a deflection off Irene Paredes and ballooned over Misa Rodriguez.
Ueki returned the favour for the third goal in the 40th minute with a through ball that Miyazawa reached on the edge of the box and hammered past Rodriguez with her right foot.
Spain came out in the second half with more purpose but for all their possession and more than 900 passes, they were unable to seriously trouble a Japan defence that has yet to concede a goal at the tournament.
- Ekaterina Koroleva