Magnesium alloys are important light metals. In recent years, they have been widely applied in the aerospace and automotive industries, and in the manufacture of communication devices, consumer-electronics appliances and computer products. However, cast magnesium and magnesium alloys are subject to problems due to gas pores, inclusion particles, oxide films, and so on. How to reduce the harm caused by these defects and refine the structure to improve casting quality has become an important topic. In this study, we evaluate the effect on casting quality of an ultrasonic method for treating the melt. The method is based on the generation of cavitation bubbles from ultrasonic treatment of the melt, which induces dispersion and degassing action. Analysis of the microstructure and determination of the mechanical properties of the resultant castings are the basis for identifying the quality of the magnesium and magnesium alloys. The microstructure was evaluated using an optical microscope and scanning electron microscopy (SEM). The elemental constituents of the inclusion particles and oxide films were identified using scanning electron microscopy in conjunction with an X-ray energy dispersive spectrometer and electron probe microanalyzer (EPMA). Finally, the mechanical properties of the magnesium and magnesium alloys, including the tensile strength, the elongation and the hardness, were also determined and discussed. In addition, variations in mechanical properties of cast aluminum and magnesium alloys by ultrasonic treatment are also discussed. [doi:10.2320/matertrans.MER2008273]