Japan booked their place in the last eight, winning a hard fought game against the north Africans, who must now beat Spain in their last match to stand any chance of progress
Nagai lobbed home with just seven minutes remaining, after racing onto a clever flicked pass from Hiroshi Kiyotake, giving the Blue Samurai a deserved win against a Moroccan side lacking any punch or penetration.
Pim Verbeek's team started brightly, fashioning a chance in the fourth minute when Nordin Amrabat timed his run into the box to perfection, but Japan skipper Maya Yoshida did just enough to put the Morocco striker off.
With the talented wingers Zakaria Labyad and Soufiane Bidaoui on either flank, it was no surprise to see the north African side utilizing the wings at every available opportunity and one such move saw them force an 18th minute corner from which Amrabat had a chance following a knockdown, but his shot was well blocked by Sakai.
Three minutes later and more terrific work on the right-flank from Bidaoui saw him bamboozle the Japanese left-back Daisuke Suzuki, but the Lierse wideman's cross was behind the onrushing Labyad and the chance was lost.
Labyad, a new arrival in the Portugese capital Lisbon this summer having completed a move to Sporting, decided he'd have a go from distance in the 34th minute, and his 30-yarder almost caught out Shuichi Gonda at his near-post, but the keeper was alert enough to make the save.
Takashi Sekizuka's side, outstanding on the counterattack in its surprise victory over Spain - when it really should have won by more than just the single goal - struggled to trouble the Moroccans in the opening 35 minutes, but almost took the lead when Yuki Otsu curled a splendid 25-yard effort just wide.
Japan's goal against Spain came from a set-piece and they almost opened the scoring in a similar manner here, not once, but twice, before the half-time interval.
First, an inswinging corner from the right found the head of Suzuki, and his header was just about stopped on the goalline by Mohammed Amsif, when some in the stadium thought it had crossed the line.
Moments later, a corner from the opposite side found the head of Yoshida, but his glancing header went wide of Amsif's left-hand post, the final chance of a lackluster half.
With the tempo noticeably quicker in the second half, Morocco set about taking control of the match, aware that a point would be a better result for its opponent than itself and forced a succession of early corners, but struggled to threaten the Japanese goal, Amrabat coming closest with a curling effort in the 58th minute, which went a yard wide.
Moments later however, and after 15 minutes spent almost exclusively in its own half, Japan was unfortunate not to be in front itself.
A swift breakaway saw the ball arrive at the feet of Hiroshi Kiyotake, who drifted from the flank into a central area, before unleashing a terrific left-footed effort which Moroccan keeper Amsif did outstandingly well to tip onto the crossbar, before collecting the ball as it landed nearby, to ensure the stalemate continued.
Bursting through midfield, Hotaru Yamaguchi played a clever one-two with the previously anonymous Nagai, but presented with a golden opportunity, the Cerezo Osaka midfielder fired his shot over the crossbar.
Now firmly in the ascendency, Japan continued to attack and with seven minutes remaining, their bold approach got its reward.
Under pressure in the center of the field, the impressive Kiyotake clipped the ball over the Morocco defense for Nagai to chase, and seeing Amsif charging from his goalline to meet him, the 23-year-old striker lobbed the ball from 30-yards into the unguarded net.
An aimless punt was flicked on by Barrada, but Labyad, clear of the last defender, saw his effort saved by Gonda, before Barrada's follow up was cleared by Tokunaga, ensuring victory for the Blue Samurai.
Follow GOAL.COM USA on