The origin of magnetic storms