Context. Magnetic energy is required to heat the corona, the outer atmosphere of the Sun, to millions of degrees. Aims. We study the nature of the magnetic energy source that is probably responsible for the brightening of coronal loops driven by nanoflares in the cores of solar active regions. Methods. We consider observations of two active regions (ARs), 11890 and 12234, in which nanoflares have been detected. To this end, we use ultraviolet (UV) and extreme ultraviolet (EUV) images from the Atmospheric Imaging Assembly (AIA) onboard the Solar Dynamics Observatory (SDO) for coronal loop diagnostics. These images are combined with the co-temporal line-of-sight magnetic field maps from the Helioseismic and Magnetic Imager (HMI) onboard SDO to investigate the connection between coronal loops and their magnetic roots in the photosphere.Results. The core of these ARs exhibit loop brightening in multiple EUV channels of AIA, particularly in its 9.4 nm filter. The HMI magnetic field maps reveal the presence of a complex mixed polarity magnetic field distribution at the base of these loops. We detect the cancellation of photospheric magnetic flux at these locations at a rate of about 10 15 Mx s −1 . The associated compact coronal brightenings directly above the cancelling magnetic features are indicative of plasma heating due to chromospheric magnetic reconnection.Conclusions. We suggest that the complex magnetic topology and the evolution of magnetic field, such as flux cancellation in the photosphere and the resulting chromospheric reconnection, can play an important role in energizing active region coronal loops driven by nanoflares. Our estimate of magnetic energy release during flux cancellation in the quiet Sun suggests that chromospheric reconnection can also power the quiet corona.