Mexico, who finish second in the group behind hosts Brazil, will face the Netherlands in the second round in Fortaleza on Sunday.
Skipper Marquez broke the deadlock with a thundering header in the 72nd minute before Andres Guardado finished off a swift counter-attack.
Hernandez made it 3-0 with a back post header from a corner and although Croatia pulled a goal back in the 87th minute through Ivan Perisic they had Ante Rebic sent-off for an awful challenge two minutes later.