  A general affine connection has enough degrees of freedom to describe the
classical gravitational and electromagnetic fields in the metric-affine
formulation of gravity. The gravitational field is represented in the
Lagrangian by the symmetric part of the Ricci tensor, while the classical
electromagnetic field is represented geometrically by the tensor of homothetic
curvature. We introduce matter as the four-velocity field subject to the
kinematical constraint in which the Lagrange multiplier represents the energy
density. A coupling between the four-velocity and the trace of the nonmetricity
tensor represents the electric charge density. We show that the simplest
metric-affine Lagrangian that depends on the Ricci tensor and the tensor of
homothetic curvature generates the Einstein-Maxwell field equations, while the
Bianchi identity gives the Lorentz equation of motion. If the four-velocity
couples to the torsion vector, the Einstein equations are modified by a term
that is significant at the Planck scale and may prevent the formation of
spacetime singularities.
