The American Journal of Roentgenology published a fascinating article back in 2001 about an incident at a MRI imaging center in western New York State. An off-duty police entered the MRI scanner room and attempted to place his Colt M1991 A1 pistol on the top of a cabinet. The pistol was wrenched from his grip by the magnetic field. It was pulled towards the machine and then discharged!
The gun likely discharged as a result of the effect of the magnetic field on the firing pin block. The firing pin block was probably drawn into its uppermost position by force of the magnetic field. The firing pin block has to overcome only light pressure from a relatively small spring to release the firing pin. The pistol was likely drawn into the magnetic field so that the muzzle struck the magnet’s bore first. With the firing pin allowed to move freely in its channel, the force of the impact on the muzzle end was sufficient to cause the firing pin to overcome its spring pressure and move forward to strike the primer of the chambered round.
This account explains how the weapon discharged when the thumb safety was engaged.
The journal article, unlike most journal articles I have read, is written in plain english and can be understood by a laymen. I recommend reading the full account of the incident.
[ Many thanks to PERRK for emailing me the link. ]