The effect of heat input on the microstructure and mechanical properties of an electron-beam-welded AZ31 magnesium alloy were investigated. Using tensile tests, it was found that the strength of the welded joints was better than that of the base metal. However, the ductility became much worse after the electron-beam welding. The heat input plays a key role in electron-beam welding for the AZ31 magnesium alloy. The results showed that both the strength and the ductility exhibited the trend of increasing first and then decreasing with increasing heat inputs, and reached their maximum values at 180 J.mm(-1) and 216 J-mm(-1), respectively. It is closely related to the macro morphologies and microstructures of the welds under different heat inputs. With increasing heat inputs, the appearances of the welds changed from nail-shape to straight-shape, which is more conducive to reducing the stress concentration during tensile deformation, the grains in the fusion zone became coarser. Many Mg17Al12 precipitates were observed in the grains of the weld. A large heat input led to an increase in the quantity and size of the precipitates in the weld. These precipitates effectively restricted the dislocation movement and improve the strength. Significantly, the fracture morphological difference between the fusion zone and base metal can be found. The fracture morphology in the base metal side was polyhedral, which was generally intergranular fracture. However, the brittle fracture was not obvious in the fusion region of the weld. Instead, a large number of fine dimples were observed at high magnification.