Full back Hernandez stretched high after five minutes to hook in the first goal Morocco have conceded to an opposition player in the tournament after a scramble in the box, but the holders offered only occasional glimpses of their class.
Morocco, disrupted by early injuries to two key defenders, recovered to cause no end of problems, with Hugo Lloris brilliantly saving Jawad El Yamiq's overhead kick at the end of the first half and the outsiders pouring forward for much of the second.
However, they could not quite fashion a clear enough chance for the equaliser and were unable to extend the astonishing run that included victories over Belgium, Spain and Portugal and made them the first African team to make the semi-finals.
France settled it in the 79th minute when a brilliant dribble by Kylian Mbappe set up Kolo Muani to tuck in the decisive goal with his first touch less than a minute after coming on.
France will be hugely relieved to become the first defending champions to reach successive finals since Brazil in 2002 and can now look forward to Sunday's showdown when they will bid to follow Brazil (1962) and Italy (1938) as the third