The definition of second-order intensity moments in the spatial domain and spatial frequency domain has been generalized for the case that the linear gain or absorbing media are included, where the wave number is generally complex. The formula for beam propagation M 2-factor of partially coherent beams in linear gain or absorbing media has been given. The partially coherent flat-topped Schell-model beam is taken as an example. The closed-form expression for the beam propagation M 2-factor of partially coherent flat-topped beam in gain or absorbing media has been derived. The changes of the M 2-factor in media have been discussed with numerical examples. It can be shown that the M 2-factor of flat-topped Schell-model beams in gain or absorbing media depends on the coherent parameter β, the coherent length σ 0 , the beam order M, the propagation distance B, the imaginary part of the wave number K i, as well as the real part of the wave number K r.