Hosts Japan held their nerve to defeat New Zealand 4-2 on penalties on Saturday and advance to the semifinals of the Tokyo Olympics men's football competition.

Captain Maya Yoshida scored the winning spot kick to seal victory in the shootout following a 0-0 draw after 120 minutes at Kashima Stadium.

Japanese players celebrate after defeating New Zealand in a penalty shootout in their men's football quarterfinal of the Tokyo Olympics on July 31, 2021, at Kashima Stadium in Ibaraki Prefecture, eastern Japan. (Kyodo)==Kyodo

Seeking their first Olympic men's football medal since winning bronze at the 1968 Mexico Games, Japan will face Spain in Tuesday's semis. Spain overcame Ivory Coast 5-2 after extra time thanks to a hat-trick from substitute Rafa Mir.

"We would've liked to have scored in the 90 minutes but New Zealand are a good team and really gave us a tough game," said Japan manager Hajime Moriyasu.

"But we tried to keep a clean sheet and go for victory and that has led to this penalty shootout win. It's going to be a tough game in the semifinals, but we will stick together as a unit and battle it out to the death and try and reach the final."

Japan should have taken the lead after 10 minutes but Wataru Endo shot wastefully off target after Daichi Hayashi's cross had picked the Stuttgart man out unmarked at the far post.

Ritsu Doan then went close on the half-hour mark, firing just wide following good work from the lively Takefusa Kubo.

New Zealand's first clear-cut chance arrived 10 minutes before the break, but Burnley striker Chris Wood blazed over the crossbar.

Another good opportunity fell Japan's way with 13 minutes of normal time remaining, but Reo Hatate's header came to nothing and New Zealand goalkeeper Michael Woud then denied substitute Ayase Ueda with a superb save from point-blank range.

After 30 minutes of extra time failed to produce a winner, the game went to a shootout and Ueda, Kou Itakura, Yuta Nakayama and Yoshida all scored to send Japan through.

"I was determined to score," said Yoshida, who was also Japan's captain when they reached the semifinals of the 2012 London Olympics before losing to Mexico and then South Korea in the bronze medal match.

"We knew it would be a really hard game and I think we were really patient. It was huge that we could stick it out at the back (and not concede) over 120 minutes," said the Sampdoria defender.

Japan goalkeeper Kosei Tani saved Liberato Cacace's effort, while Clayton Lewis also missed for New Zealand.

"I was more determined than anyone to prevent (New Zealand) from scoring and that played a part in this result," said Tani. "I just wanted to do anything I could to stop a penalty and help us get to the next round."

Japan drew 1-1 with Spain on July 17 in their final warm-up before the Olympics.

In Saturday's other quarterfinal matches, Brazil edged Egypt 1-0 to set up a meeting in the last four with Mexico, who overpowered South Korea 6-3.