The friction rotary welding (FRW) of magnesium alloy to aluminum alloy was presented in a paper due to significant interest in the manufacturing industry. A genetic algorithm (GA) method for optimizing FRW process parameters of dissimilar light alloys was presented. After obtaining the welding parameters by GA method, it was possible to determine the best tensile strength of the friction joint. The obtained joints were subjected to tensile strength. The highest tensile strength TS = 178 MPa was found using a genetic algorithm for the following friction welding parameters: friction force FF = 16 kN, friction time FT = 4 s, and upsetting force UF = 44 kN. The optimized values were compared with the experimental results. The application of the genetic algorithm method allowed increasing the tensile strength joint from 88 to 180 MPa. The maximum tensile strength of the friction welded magnesium alloy-aluminum alloy joints was 73% of the base AZ31B metal. The relationship between welding parameters and strenght of welds was also demonstrated in this study.