The lithiation and magnesiation of binary R5Sn3 (R = Y and Gd) phases has been studied by XRD, SEM, EPMA and electrochemical methods. The formation of R5Sn3Lix and R5Sn3Mgx ternary hexagonal phases as the results of insertion of Li/Mg into octahedral voids were observed during the first stage of electrochemical lithiation and magnesiation respectively. During the second stage of the electrochemical lithiation and magnesiation is the decomposition of the hexagonal phase into new phases and substitution of tin atoms by Li/Mg are observed.