The increasing demand for high-performance lightweight metallic materials is driving an interest in Plasma Electrolytic Oxidation (PEO) as one of the most promising techniques for surface engineering of Mg. In order to enable smart and multifunctional performance, it can be beneficial to incorporate into ceramic PEO coatings nanocontainers to carry appropriate active and functionalising agents. In situ incorporation of nanocontainers is challenging since their integrity may be compromised by plasma discharge assisting coating formation. We studied incorporation of halloysite nanotubes (HNTs) as potential nanocontainers into forsterite, Mg2SiO4, formed during PEO processing of AM50 alloy at the frequency range of 100-5000 Hz. Detailed analysis of the coating microstructure, chemical and phase composition carried out by Scanning Electron Microscopy/Energy Dispersive X-ray Spectroscopy, Transmission Kikuchi Diffraction and X-ray Diffraction enabled evaluation of a pattern of surface temperature evolution during current pulses underpinning the PEO process. Transient analysis revealed that at pulses longer than 10-4 s, the surface heating becomes affected by the metal substrate acting as a heat sink. As the pulse duration approaches 10-3 s, raising surface temperature and increasing thermal gradients across the coating cause crystallisation of forsterite and grain growth towards the surface; this triggers thermally induced degradation and decomposition of HNTs adsorbed on the surface. In contrast, at short pulse durations (2×10-5 s), the energy released is insufficient to induce forsterite crystallisation and incorporated HNTs are retained in their original tubular structure. Due to the fine porosity and good structural integrity, such coatings show enhanced corrosion resistance in saline solution. Strong correlations between surface thermodynamic conditions and evolution of coating microstructure disambiguate the fundamental mechanisms underlying incorporation of nanoparticles into growing PEO coatings, thus creating the basis for efficient design of PEO processes and development of novel smart and multifunctional coatings with potential applications in many industrial sectors.