Severe droughts and floods in 9th-century China may have triggered migration, weakened border defenses, and accelerated the fall of the Tang dynasty.