In a process for producing a gas largely free of inert gases for the synthesis of alcohols, particularly methanol, and of hydrocarbons from coal or heavy hydrocarbons by gasification under pressure with oxygen and steam, the crude gas is cooled, the impurities are removed by washing with methanol and the methanol is removed from the cold pure gas by molecular sieves. The pure gas is then cooled further by evaporation and methane is distilled from the liquid part while simultaneously obtaining the synthetic gas consisting of hydrogen and carbon monoxide which is largely free of methane. The methane is wholly or partly compressed and then split into carbon monoxide and hydrogen using steam and oxygen. The split gas is fed back and mixed with the synthesis gas or the partly cleaned crude gas. The synthesis gas heated to the ambient temperature, freed of impurities and free of methane is compressed to the required synthesis pressure.