
Hernandez broke the deadlock from the penalty spot in first-half stoppage time after a late challenge from Fabiano Parisi.
Tommaso Pobega had come close to putting Milan ahead late in the first half with a header towards the near post but Fiorentina keeper Pietro Terracciano managed to get a hand to it.
Fiorentina nearly equalised around the hour mark when Nico Gonzalez’s cross deflected off a Milan defender and clipped the far post.
Deep into stoppage time Milan keeper Mike Maignan saved a close-range shot from Rolando Mandragora with his face.
Milan are third in the table with 26 points, five behind leaders Inter Milan. Fiorentina are sixth with 20 points.