Magnesium and magnesium alloys, the lightest structural materials, have been received plenty of global attention recently. These alloys could be applied in various fields, especially the electronics industry, because of their excellent electromagnetic interference shielding. However, the welding technique of magnesium alloys has not been established. This study is related to the welding of AZ31B magnesium alloy by a short-pulsed a Nd:YAG laser. Two types of pulse waves, square pulse and variable pulse, were used to control weld defects. Results show that the crack and porosity, generated in the weld, had not been controlled by general square pulse. But through the application of variable pulse, the defects could be prevented and the good weld zone was obtained.