Extended gas clouds have been previously detected surrounding the brightest known close-in transiting hot Jupiter exoplanets, HD209458 b and HD189733 b; we observed the distant but more extreme close-in hot Jupiter system, WASP-12, with Hubble Space Telescope (HST). Near-UV (NUV) transits up to three times deeper than the optical transit of WASP-12 b reveal extensive diffuse gas, extending well beyond the Roche lobe. The distribution of absorbing gas varies between visits. The deepest NUV transits are at wavelength ranges with strong stellar photospheric absorption, implying that the absorbing gas may have temperature and composition similar to those of the stellar photosphere. Our spectra reveal significantly enhanced absorption (greater than 3 sigma below the median) at similar to 200 individual wavelengths on each of two HST visits; 65 of these wavelengths are consistent between the two visits, using a strict criterion for velocity matching that excludes matches with velocity shifts exceeding similar to 20 km s(-1). Excess transit depths are robustly detected throughout the inner wings of the Mg II resonance lines independently on both HST visits. We detected absorption in Fe II lambda 2586, the heaviest species yet detected in an exoplanet transit. The Mg II line cores have zero flux, emission cores exhibited by every other observed star of similar age and spectral type are conspicuously absent. WASP-12 probably produces normal Mg II profiles, but the inner portions of these strong resonance lines are likely affected by extrinsic absorption. The required Mg+ column is an order of magnitude greater than expected from the interstellar medium, though we cannot completely dismiss that possibility. A more plausible source of absorption is gas lost by WASP-12 b. We show that planetary mass loss can produce the required column. Our Visit 2 NUV light curves show evidence for a stellar flare. We show that some of the possible transit detections in resonance lines of rare elements may be due instead to non-resonant transitions in common species. We present optical observations and update the transit ephemeris.