Context. Classical T Tauri stars are young solar-type stars accreting material from their circumstellar disks. Thanks to a favorable inclination of the system, the classical T Tauri star AA Tau exhibits periodic optical eclipses as the warped inner disk edge occults the stellar photosphere. Aims. We intend to observe the X-ray and UV emission of AA Tau during the optical eclipses with the aim of localizing these emitting regions on the star. Methods. AA Tau was observed for about 5 h per XMM-Newton orbit (2 days) over 8 successive orbits, which covers two optical eclipse periods (8.22 days). The XMM-Newton optical/UV monitor simultaneously provided UV photometry (UVW2 filter at 206 nm) with a ∼15 min sampling rate. Some V-band photometry was also obtained from the ground during this period in order to determine the dates of the eclipses. Results. Two X-ray and UV measurements were secured close to the center of the eclipse (∆V ∼ 1.5 mag). The UV flux is the highest just before the eclipse starts and the lowest towards the end of it. UV flux variations amount to a few 0.1 mag on a timescale of a few hours and up to 1 mag on a timescale of a week, none of which are correlated with the X-ray flux. We model it with a weekly modulation (inner disk eclipse), plus a daily modulation, which suggests a non-steady accretion, but needs a longer observation to be confirmed. No such eclipses are detected in X-rays. Within each 5 h-long observation, AA Tau has a nearly constant X-ray count rate. On a timescale of days to weeks, the X-ray flux varies by a factor of 2−8, except for one measurement where the X-ray count rate was nearly 50 times higher than the minimum observed level even though photoelectric absorption was the highest at this phase, and the plasma temperature reached 60 MK, i.e. a factor of 2−3 higher than in the other observations. This X-ray event, observed close to the center of the optical eclipse, is interpreted as an X-ray flare. Conclusions. We explain the variable column density with the low-density accretion funnel flows blanketing the magnetosphere. The lack of X-ray eclipses indicates that X-ray emitting regions are located at high latitudes. Furthermore, the occurrence of a strong X-ray flare near the center of the optical eclipse suggests that the magnetically active areas are closely associated with the base of the high-density accretion funnel flow. We speculate that the impact of this free-falling accretion flow onto the strong magnetic field of the stellar corona may boost the X-ray emission.