Ultralight dark matter (such as kinetically mixed dark-photon dark matter or axionlike dark matter) can source an oscillating magnetic-field signal at the Earth’s surface, which can be measured by a synchronized array of ground-based magnetometers. The global signal of ultralight dark matter can be robustly predicted for low masses, when the wavelength of the dark matter is larger than the radius of the Earth, λDM ≫ R. However, at higher masses, environmental effects, such as the Schumann resonances, can become relevant, making the global magnetic-field signal B difficult to reliably model. In this work, we show that ∇ × B is robust to global environmental details, and instead only depends on the local dark matter amplitude. We therefore propose to measure the local curl of the magnetic field at the Earth’s surface, as a means for detecting ultralight dark matter with λDM ≲ R. As this measurement requires vertical gradients, it can be done near a hill/mountain. Our measurement scheme not only allows for a robust prediction, but also acts as a background rejection scheme for external noise sources. We show that our technique can be the most sensitive terrestrial probe of dark-photon dark matter for frequencies 10 Hz ≤ $$ {f}_{A^{\prime }} $$
f
A
′
≤ 1 kHz (corresponding to masses 4 × 10−14 eV ≤ $$ {m}_{A^{\prime }} $$
m
A
′
≤ 4 × 10−12 eV). It can also achieve sensitivities to axionlike dark matter comparabe to the CAST helioscope, in the same frequency range.