Inspired by the social behavior of birds or fish swarms, particle swarm optimization (PSO) is used to solve many engineering optimization problems. The PSO algorithm is mostly applied to the geophysical parametric inversion based on specific models, and it is rarely used to implement the physical property inversion of geophysical data. We have applied the standard PSO algorithm to the 2D inversion of magnetic data to recover the distribution of subsurface magnetization intensity. To manage the over-stochastic problem of a standard PSO inversion, the velocities of particle swarms are smoothed, and the -means clustering model constraint to the objective function is implemented to distinguish the multiple magnetic sources in the case of the complicated magnetic anomaly. The PSO inversion of magnetic data is tested using synthetic models. In the field examples of Galinge and Weigang iron ore deposits in China, concealed iron orebodies were detected, and the reconstructed magnetic source distribution yielded good agreement with the orebodies inferred from drillhole information. The uncertainty analysis results demonstrated that the recovered models using the PSO algorithm had lower reliability for the bottom and boundary areas of target sources because of the influence of observation noise and the weak magnetic response of deep-buried sources. The PSO algorithm obtained a sharp physical property distribution and demonstrated strong global optimization ability.