We characterize the smallest codimension components of the Hodge locus of smooth degree d hypersurfaces of the projective space ℙn+1 of even dimension n, passing through the Fermat variety (with d≠3,4,6). They correspond to the locus of hypersurfaces containing a linear algebraic cycle of dimension n2. Furthermore, we prove that among all the local Hodge loci associated to a nonlinear cycle passing through Fermat, the ones associated to a complete intersection cycle of type (1,1,…,1,2) attain the minimal possible codimension of their Zariski tangent spaces. This answers a conjecture of Movasati, and generalizes a result of Voisin about the first gap between the codimension of the components of the Noether–Lefschetz locus to arbitrary dimension, provided that they contain the Fermat variety.