Nutrient-poor, serpentinitic soils in the San Francisco Bay area sustain a native grassland that supports many rare species, including the Bay checkerspot butterfly (Euphydryas editha bayensis). Nitrogen (N) deposition from air pollution threatens biodiversity in these grasslands because N is the primary limiting nutrient for plant growth on serpentinitic soils. I investigated the role of N deposition through surveys of butterfly and plant populations across different grazing regimes, by literature review, and with estimates of N deposition in the region. Several populations of the butterfly in south San Jose crashed following the cessation of cattle grazing. Nearby populations under continued grazing did not suffer similar declines. The immediate cause of the population crashes was rapid invasion by introduced annual grasses that crowded out the larval host plants of the butterfly. Ungrazed serpentinitic grasslands on the San Francisco Peninsula have largely resisted grass invasions for nearly four decades. Several lines of evidence indicate that dry N deposition from smog is responsible for the observed grass invasion. Fertilization experiments have shown that soil N limits grass invasion in serpentinitic soils. Estimated N deposition rates in south San Jose grasslands are 10–15 kg N/ha/year; Peninsula sites have lower deposition, 4–6 kg N/ha/year. Grazing cattle select grasses over forbs, and grazing leads to a net export of N as cattle are removed for slaughter. Although poorly managed cattle grazing can significantly disrupt native ecosystems, in this case moderate, well-managed grazing is essential for maintaining native biodiversity in the face of invasive species and exogenous inputs of N from nearby urban areas.