The results of studies into AZ31 magnesium powder selective laser melting process optimization are presented in this paper. Optimization was aimed at minimizing the melted material porosity and determining the influence of and correlations between the analyzed process parameters. Design of experiments (DOE) approach was used, specifically full factorial design for three factors and rotatable design for two factors. Satisfactory porosity values were obtained in the <0.5% range. The results were used to prepare a mathematical model for the resulting porosity depending on the parameters used. Additionally, it was shown that information on linear energy density and scan velocity is not sufficient to describe the SLM process, and that it is necessary to provide detailed values of component parameters.