• The thickness variation of intermetallic compounds (IMCs) along the Al/Mg boning interface were characterized. • Ultrasonic vibration can reduce the thickness of IMCs on the whole Al/Mg boning interface. • The maximum thickness of IMCs locates at about 1 mm below the top surface of welds on transverse cross-section. • The variation trend of average thickness of IMCs on two horizontal cross-sections were compared and analyzed. The formation of intermetallic compounds (IMCs) in friction stir welding of Al and Mg alloys worsens the strength and toughness of dissimilar joints. Understanding of the morphology and thickness variation of IMCs at different locations inside the weld will lay solid foundation for mitigating the unfavorable effects of IMCs. In this study, friction stir welding tests of Al/Mg alloys with and without exertion of ultrasonic vibration were performed, and the distribution of IMCs at transverse and horizontal cross-sections of welds were observed and characterized at more checking points. The results show that as the depth distance from the top surface of weld gets larger, the thickness of IMCs on transverse cross-section increases first and then decreases, and reaches the maximum value at a depth of about 1 mm. On the horizontal plane at upper part of weld, the thickness of IMCs first increases and then decreases as the distance gets farther from the center of the exit hole, and reaches a stable stage outside of the range covered by the shoulder. The application of ultrasonic vibration can reduce the thickness of IMCs in the whole weld, and make the peak value of IMCs thickness appear at a location nearer the exit hole on horizontal planes at both upper and lower parts of weld.