A diffractive optical element is fabricated with relative ease in a glass containing spherical silver nanoparticles 30 to 40 nm in diameter and embedded in a surface layer of thickness ~10 μm. The nanocomposite was sandwiched between a mesh metallic electrode with a lattice constant 2 μm, facing the nanoparticle containing layer and acting as an anode, and a flat metal electrode as cathode. Applying moderate direct current electric potentials of 0.4 kV and 0.6 kV at an elevated temperature of 200 °C for 30 minutes across the nanocomposites led to the formation of a periodic array of embedded structures of metallic nanoparticles. The current-time dynamics of the structuring processes, optical analyses of the structured nanocomposites and diffraction pattern of one such fabricated element are presented.