This paper considers gravitational perturbations in geometrically thin disks with rotation curves dominated by a central object, but with substantial contributions from magnetic pressure and tension. The treatment is general, but the application is to the circumstellar disks that arise during the gravitational collapse phase of star formation. We find the dispersion relation for spiral density waves in these generalized disks and derive the stability criterion for axisymmetric $(m=0)$ disturbances (the analog of the Toomre parameter $Q_T$) for any radial distribution of the mass-to-flux ratio $lambda$. The magnetic effects work in two opposing directions: on one hand, magnetic tension and pressure stabilize the disk against gravitational collapse and fragmentation; on the other hand, they also lower the rotation rate making the disk more unstable. For disks around young stars the first effect generally dominates, so that magnetic fields allow disks to be stable for higher surface densities and larger total masses. These results indicate that magnetic fields act to suppress the formation of giant planets through gravitational instability. Finally, even if gravitational instability can form a secondary body, it must lose an enormous amount of magnetic flux in order to become a planet; this latter requirement represents an additional constraint for planet formation via gravitational instability and places a lower limit on the electrical resistivity.