To understand the evolution of the Moon, we numerically modeled mantle convection and magmatism in a two‐dimensional polar rectangular mantle. Magmatism occurs as an upward permeable flow of magma generated by decompression melting through the convecting matrix. The mantle is assumed to be initially enriched in heat‐producing elements (HPEs) and compositionally dense ilmenite‐bearing cumulates (IBC) at its base. Here, we newly show that magma generation and migration play a crucial role in the calculated volcanic and radial expansion/contraction history. Magma is generated in the deep mantle by internal heating for the first several hundred million years. A large volume of the generated magma ascends to the surface as partially molten plumes driven by melt buoyancy; the magma generation and ascent cause a volcanic activity and radial expansion of the Moon with the peak at 3.5–4 Gyr ago. Eventually, the Moon begins to radially contract when the mantle solidifies by cooling from the surface boundary. As the mantle is cooled, the activity of partially molten plumes declines but continues for billions of years after the peak because some basal materials enriched in the dense IBC components hold HPEs. The calculated volcanic and radial expansion/contraction history is consistent with the observed history of the Moon. Our simulations suggest that a substantial fraction of the mantle was solid, and there was a basal layer enriched in HPEs and the IBC components at the beginning of the history of the Moon.