The evolutionary part of Maxwell's equations has a Lagrangian written in terms of the electric and magnetic fields, but admit neither Lorentz nor conformal transformations. The additional equations on vanishing the divergences of the electric and magnetic fields guarantee the Lorentz and conformal invariance, but the resulting overdetermined system does not have a Lagrangian. The aim of the present paper is to attain a harmony between these two contradictory properties.