The nuclear interactions of solar-flare-accelerated protons and ions with the solar atmosphere and the deeper layers of the Sun lead to the formation of several stable and radioactive isotopes. This article examines the GEANT4 depth profiles of 2H, 3H, 3He, 6Li, 7Li, 10Be, and 14C. When accelerated particles pass through a layer of 0.1–2 g cm–2, 6Li, 7Li, 10Be, and 14C isotopes form in sufficient amounts to explain their anomalous abundances in lunar soil samples. It is assumed that they escape into interplanetary space with coronal mass ejections immediately after the flare.