The Maxwell–Klein–Gordon equations are a set of coupled nonlinear time‐dependent wave equations, used to model the interaction of an electromagnetic field with a particle. The solutions, expressed with a magnetic vector potential, are invariant under gauge transformations. This characteristic implies a constraint on the solution fields that might be broken at the discrete level. In this article, we propose and study a constraint preserving numerical scheme for this set of equations in dimension 2. At the semidiscrete level, we combine conforming Finite Element discretizations with the so‐called Lattice Gauge Theory to design a compatible gauge invariant discretization, leading to preservation of a discrete constraint. Relying on energy techniques and compactness arguments, we establish the convergence of this semidiscrete scheme, without a priori knowledge of the solution. Finally, at the fully discrete level, we propose a compatible explicit time‐integration strategy of leapfrog type. We implement the resulting fully discrete scheme and provide assessment on academic scenarios.