And Dovid built there a Mizbe'ach unto Hashem, and offered olot (burnt offerings) and shelamim (peace offerings). So Hashem was entreated for the land, and the magefah (plague, see Isa 53:8) was withdrawn from Yisroel.