Magnesium-doped silica membranes were synthesized and a large increase in H2/CO2 permselectivity is achieved as compared to undoped silica membranes. Three magnesium concentrations were studied, namely 10, 15 and 20 mol%, in order to find the optimal Mg-concentration for the highest H2/CO2 separation performance. The physical properties of these sol-gel derived Mg-doped silica gels and membranes were characterized by dynamic light scattering, X-ray diffraction and high-resolution scanning electron microscopy. After the incorporation of magnesium into amorphous silica network, the membrane structure remained amorphous. Membrane performance was tested by single gas permeance of He, H2, CO2, N2 and CH4. With 20 mol% Mg doping, H2/CO2 permselectivity values of more than 350 were achieved with a H2 permeance of 70 × 10−9 mol m−2 s−1 Pa−1. For pure silica membranes, a H2/CO2 permselectivity of 9 was observed with a H2 permeance of 526 × 10−9 mol m−2 s−1 Pa−1.